fstab and cifs mounting, possible to store authentication information outside of fstab?
Solution 1:
From the mount.cifs manpage:
credentials=filename specifies a file that contains a username and/or password. The format of the file is: username=value password=value This is preferred over having passwords in plaintext in a shared file, such as /etc/fstab. Be sure to protect any credentials file properly.
Solution 2:
Use the credentials option such as:
http://www.justlinux.com/nhf/Filesystems/Mounting_smbfs_Shares_Permanently.html
Example from the website:
cd
echo username=mywindowsusername > .smbpasswd
echo password=mywindowspassword >> .smbpasswd
chmod 600 .smbpasswd
Substitute your Windows username and password in the commands. No one else except root would be able to read the contents of this file.
Once that is created, you would modify the line in the /etc/fstab file to look like this:
//servername/sharename /mountdirectory smbfs credentials=/home/myhomedirectory/.smbpasswd 0 0
example from /etc/fstab:
//server/share/ /mnt/localmountpoint cifs credentials=/root/.creda
janneb's post and the link to man page show what needs to be present in the credentials file.
Solution 3:
So I'm accumulating both answers
-
Create file, e.g. /root/.cifs
username=value password=value domain=value (optional)
-
set permission
600
(rw- permission) to protect your credentials# chmod 600 /root/.cifs
pass
credentials=/root/.cifs
to your command instead ofusername=
andpassword=
Solution 4:
Could try cifscloak
pip3 install cifscloak
https://github.com/sudoofus/cifscloak