SMB Mount With autofs¶
install autofs cifs-utils
touch /etc/auto.cifs nano /etc/auto.cifs
Add this to the file: ("media" - is any name for your mount)
active-share -fstype=cifs,rw,noperm,vers=3.0,credentials=/etc/.credentials.txt ://oscar.3os.re/active-share
Exit and save:
touch /etc/.credentials.txt nano /etc/.credentials.txt
Add you credentials for the smb mount:
Exit and save:
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/ ls
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.