Mount Protected Network Shares Securely (no password prompts)

Gotenks
  13 years ago
  10

Adapted from Mount Windows Shares Permanently

I use Windows Home Server (WHS) which uses CIFS access by default. Linux Mint allows you to access shares easily from nautilus automagically. When it comes to apps like VLC trying to play files from those mounted points, it won't work. Here is the solution:

Install the filesystem

sudo apt-get install smbfs

Create mount folder

mkdir /media/mountname

su

nano /etc/fstab

Add the following in fstab for read/write permission:

//serverip/mountname  /media/mountname  cifs defaults,uid=1000,gid=1000,credentials=/home/username/.smbcredentials,umask=777  0  0

(Copy above from top to bottom into your notepad, it's all there this site just won't show it.)

Correct serverip,mountname,username to yours

Create a file that fstab will reference for the network shares username/password

nano /home/username/.smbcredentials

Enter in:

username=myusername
password=mypassword

save it 'Ctrl+x' press 'y' then enter

Change permissions on .smbcredentials so only you have permission to read and write to it.

chmod 600 .smbcredentials

Finally mount it all as root

mount -a

Fixing a CIFS bug with Network Manager

If you use network manager, and are getting really slow shutdowns. It's probably because the network manager shuts down before unmounting the network shares. That will cause CIFS to hang, and wait for 60 seconds or so. Here's what you do to fix it:

sudo ln -s /etc/init.d/umountnfs.sh /etc/rc0.d/K14umountnfs.sh
sudo ln -s /etc/init.d/umountnfs.sh /etc/rc6.d/K14umountnfs.sh

Comments
acewolk 11 years ago

Awesome, thanks. May need to use:

sudo apt-get install cifs-utils


instead of:

sudo apt-get install smbfs


remoulder 13 years ago

@Clem: There seems to be clipping on the RHS of the fstab line when displaying this under FF 3.6.8. The line is truncated after the 'l' in credentials by the border.