How to mount password protected windows shared folder in ubuntu

Mount temporarily

sudo mount.cifs //192.168.1.9/invoice -o username=xxx /mnt/

 

Mount permanently (surive reboot)

Install cifs

sudo apt-get install cifs-utils

Create a mount directory

sudo mkdir /media/windowsshare

Create a file to store your fileserver credential

sudo nano ~/.smbcredentials

Your file name .smbcredentials must contain the following.

username=administrator@domain.com
password=admin_password

Change file permission to proect your admin credential.

chmod 600 ~/.smbcredentials

Edit your /etc/fstab and add the following line

#Mount
//192.168.1.200/writable /media/windowsshare cifs credentials=/home/kim/.smbcredentials,iocharset=utf8,sec=ntlm 0 0
#If you get error use below
//192.168.1.200/writable /media/windowsshare cifs credentials=/home/kim/.smbcredentials,iocharset=utf8,sec=ntlm 0 0 noserverino

You may take below shortcut but it’s not recommended as your login ID and password is exposed.

//192.168.1.200/writable /media/windowsshare cifs username=admin,password=password,iocharset=utf8,sec=ntlm 0 0

You may use the following for unprotected shared folder

//192.168.1.200/writable /media/windowsshare cifs guest,uid=1000,iocharset=utf8 0 0

Finally test your mount. Restart your server to see if it mounts automatically.

sudo mount -a

To unmount network folder

sudo umount /media/windowsshare/

 

iocharset=utf8 allows access to files with names in non-English languages

If there is any space in the server path, you need to replace it by \040, for example //ServerName/My\040Documents

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top