Linux: Permanent CIFS/SMB mount

I needed to permanently mount a directory on a Windows server that had spaces in the path. I also wanted to use a credentials file so that the remote server username and password would not be in the world readable fstab file. The following was cobbled together from:

Mount samba shares with utf8 encoding using cifs

and:

Mount password protected network folders



  1. Create a credentials file (as root) containing the username and password and restrict it's ability to be read by other users (/etc/fstab is world readable).
    1. vi /root/.smbcredentials
      username=someusername
      password=somepassword
    2. Save and exit the file. Change the file permissions to only be readable by root.
      chmod 600 /root/.smbcredentials

  2. Update the fstab file
    1. Add the following line to /etc/fstab (spaces are replaced with \040 or the mount will fail)
      //ip address/c$/Program\040Files/Microsoft\040SQL\040Server/ /var/backups/Server cifs credentials=/root/.smbcredentials,iocharset=utf8,sec=ntlm 0 0
    2. Exit and save the file
  3. Test the fstab entry with:
    sudo mount -a

Comments

Popular posts from this blog

YumRepo Error: All mirror URLs are not using ftp, http[s] or file

Plesk - Decrypt FTP Passwords