Skip to content

Support us

Authors: fire1ce | Created: 2021-08-27 | Last update: 2022-07-09

SMB Mount With autofs

Install autofs cifs-utils

apt install -y autofs cifs-utils

Eddit auto.cifs file

nano /etc/auto.cifs

Add this to the file: ("media" - is any name for your mount)

media    -fstype=cifs,rw,noperm,vers=3.0,credentials=/etc/.credentials.txt    ://

Create credentials file

nano /etc/.credentials.txt

Add you credentials for the smb mount:


Exit and save:

nano /etc/auto.master

At the end of the file add: ("/mnt" - mount location, /etc/auto.cifs your config for mounting the SMB Share)

/mnt    /etc/auto.cifs --timeout=600 --ghost

Save end exit. Test the mounting.

systemctl start autofs
cd /mnt/media/

You should see the mount over there. Enable autofs on boot:

systemctl enable autofs

SMB Mount on Linux With Credentials

sudo apt-get install cifs-utils
nano ~/.smbcredentials

add this to the config.


Save the file, exit the editor. Change the permissions of the file to prevent unwanted access to your credentials:

chmod 600 ~/.smbcredentials

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):

//servername/sharename /media/windowsshare cifs vers=1.0,credentials=/home/ubuntuusername/.smbcredentials,iocharset=utf8,sec=ntlm 0 0

Save the file, exit the editor.

Finally, test the fstab entry by issuing:

sudo mount -a

If there are no errors, you should test how it works after a reboot. Your remote share should mount automatically.