{"id":167,"date":"2011-04-06T09:01:45","date_gmt":"2011-04-06T13:01:45","guid":{"rendered":"http:\/\/fazigu.org\/blog\/?p=167"},"modified":"2011-04-06T09:09:15","modified_gmt":"2011-04-06T13:09:15","slug":"mounting-windows-shares-on-linux","status":"publish","type":"post","link":"https:\/\/fazigu.org\/blog\/2011\/04\/06\/mounting-windows-shares-on-linux\/","title":{"rendered":"Mounting Windows Shares On Linux"},"content":{"rendered":"<p>There must be a gazillion posts on this, so I&#8217;m just going to concentrate on what I did wrong.<\/p>\n<p>First I wanted to mount the target share as NFS, but the server doesn&#8217;t export to our desktop subnet at work.  I saw it was running Samba, and remembered having had it working on Windows XP, so tried that.  A friend at work had an <tt>\/etc\/fstab<\/tt> line that <em>almost<\/em> worked.<\/p>\n<p>Turns out <tt>smbfs<\/tt> is deprecated and <tt>cifs<\/tt> is the new <tt>smbfs<\/tt>, so there was a documentation detour of sorts.  Anyway, I contacted infrastructure and they gave me a line that worked, but included the password.  My coworker&#8217;s line used a credentials file, and I&#8217;d prefer that, because I&#8217;m old-school anal about including passwords in the clear and logging in as root and that kind of thing.<\/p>\n<p>So, I took the infrastructure guy&#8217;s fstab line, turned it into a mount command, ran it with three verbose flags, and saw it was trying to log me in as root, even though my credentials file included my own username.<\/p>\n<p>The fix turned out to be to explicitly add another <tt>username<\/tt> option to the line:<\/p>\n<pre lang=\"bash\">\/\/samba-server\/dude \/ext\/dev\/dude cifs rw,credentials=\/home\/dude\/.ntcred\/dev,username=dude,uid=dude,gid=dude,auto,user 0 0<\/pre>\n<p>Replace &#8220;dude&#8221; with your username everywhere.  Here&#8217;s my <tt>~\/.ntcred\/dev file:<\/tt><\/p>\n<pre lang=\"config\">username=dude\r\npassword=dude-password\r\ndomain=dev<\/pre>\n<p>Replace everything with the appropriate values.\u00a0 I&#8217;m not sure the  domain even matters in this case, but it&#8217;s the NT domain\/workgroup of  the share.<\/p>\n<p>I think the root of the problem is the parsing of credentials files.\u00a0 Apparently extraneous whitespace causes it to b0rk itself up.<\/p>\n<p>Oh, and the &#8220;user&#8221; option (to allow any user to mount it, as opposed to just root, or the conflicting &#8220;user&#8221; option to samba) won&#8217;t work unless you set the cifs commands suid root:<\/p>\n<p><tt>chmod +s \/sbin\/*mount.cifs<\/tt><\/p>\n<p>Your package manager will probably gripe and\/or change that back whenever an upgrade comes up, and since we&#8217;re using &#8220;auto&#8221; it&#8217;s going to be mounted on boot, anyway, so you might as well just sudo the mount the first time and then rest easy.<\/p>\n<p>While I was at it, I tried mounting a few other shares on another domain.\u00a0 One works fine.\u00a0 When I try to enter any subdirectories of the other, everything goes to hell.\u00a0\u00a0 So, whatever.\u00a0 I&#8217;m done.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There must be a gazillion posts on this, so I&#8217;m just going to concentrate on what I did wrong. First I wanted to mount the target share as NFS, but the server doesn&#8217;t export to our desktop subnet at work. I saw it was running Samba, and remembered having had it working on Windows XP, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[24,26,23,25],"class_list":["post-167","post","type-post","status-publish","format-standard","hentry","category-hacking","tag-cifs","tag-linux","tag-samba","tag-sysadmin"],"_links":{"self":[{"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/posts\/167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/comments?post=167"}],"version-history":[{"count":10,"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/posts\/167\/revisions"}],"predecessor-version":[{"id":178,"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/posts\/167\/revisions\/178"}],"wp:attachment":[{"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/media?parent=167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/categories?post=167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fazigu.org\/blog\/wp-json\/wp\/v2\/tags?post=167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}