Method #1 - /etc/fstab
I realize you're looking for alternatives to this but here's specifically how to get your credentials out of the /etc/fstab
file:
//WindowsHost/Sharename /LocalMountPoint cifs credentials=/etc/cifsauth 0 0
Then in the file /etc/cifsauth
:
username=someuser
password=somepass
Make this file's permissions 600
, i.e. chmod 600 /etc/cifsauth
.
Method #2 - pam_mount
You can install pam_mount and then setup a generic mount for all users that login such as this:
# /etc/security/pam_mount.conf.xml
<debug enable="1" />
<volume server="server" path="music" mountpoint="~/MyMusicFolder" options="cred=/home/%(USER)/.Music.cred" />
This method still has the same problem as method #1, where the credentials are stored in a file, /home/%(USER)/.Music.cred
. This is the same type of credential file as in the first method, so make sure the permissions are 600 as well.
Method #3 - use gvfs-mount
This U&L Q&A titled: Can I automate mounting a cifs share without storing my password in plaintext? contains an answer by @Gilles which describes using the GNOME Keyring to retain your CIFS credentials.
You can then access the CIFS shares using GVFS - GNOME Virtual File System - like this:
$ gvfs-mount smb://username\;workgroupname@hostname/sharename
This will map the share from hostname called sharename and mount it under $HOME/.vfs/sharename on hostname
. You can't control this in any way. It's hardcoded to always be mounted here, I've looked!
You can however create links to these mounts which is what I do so that I can access shares that I have mounted. The use of .gvfs
was unfortunate because some tools do not list the dot directories in the file browsing so often the link I've created is the only way to access these shares.