Skip to main content

Mounting a Network Drive in Ubuntu


In this post we will look at how mount a network drive in Ubuntu.
Install CIFS:
[pre class="brush:bash"]
sudo apt-get install cifs-utils[/pre]
Mount password protected network folders
Using a text editor, create a file for your remote servers logon credential:
[pre class="brush:bash"]
gedit ~/.smbcredentials[/pre]
Enter your Windows username and password in the file:
[pre class="brush:bash"]
username=msusername
password=mspassword[/pre]
Save the file, exit the editor.
Change the permissions of the file to prevent unwanted access to your credentials:
[pre class="brush:bash"]
chmod 600 ~/.smbcredentials[/pre]
Then edit your /etc/fstab file (with root privileges) to add this line (replacing the insecure line in the example above, if you added it):
[pre class="brush:bash"]
//servername/sharename /media/windowsshare cifs credentials=/home/ubuntuusername/.smbcredentials,iocharset=utf8,sec=ntlm 0 0[/pre]
If you want to mount the SMB drive with write access
[pre class="brush:bash"]
//servername/sharename /media/windowsshare cifs credentials=/home/ubuntuusername/.smbcredentials,uid=1000,gid=1000,iocharset=utf8,sec=ntlm 0 0[/pre]
Save the file, exit the editor.
Finally, test the fstab entry by issuing:
[pre class="brush:bash"]
sudo mount -a[/pre]
More secure way of login in: Following command will ask the password when entered:
[pre class="brush:bash"]
sudo mount -t cifs //10.1.1.1/network_share /media/mount_directory -o sec=ntlmssp,uid=1000,gid=1000,user=username[/pre]
Source: https://wiki.ubuntu.com/MountWindowsSharesPermanently

You may also interested in reading:

Comments