Right now I give my users these instructions. It mounts our company samba share using fstab.

sudo mkdir /mnt/simsamba
echo "//atlas/data$ /mnt/simsamba cifs credentials=/root/.credentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0" >> sudo tee -a /etc/fstab
sudo echo "username=$USER" > /root/.credentials
echo "password=" >> /root/.credentials
chmod 600 /root/.credentials
nano /root/.credentials
#  Complete both lines by entering your active-directory username/password and saving it here (no space after the =)

There are two major problems with this:

  1. User-specific credentials are used machine-wide. That means if another user ssh's into this machine they'll access the samba mount using the host's credentials.
  2. User credentials are stored in clear-text.

Another way to do it is to simply have the user run this whenever they log in:

sudo mount -t cifs -o user=$USER //atlas/data$ ~/shared_drive

But I'd like to automate this. I could put that line in ~/.bashrc, but then they would need to enter their password whenever they launch a new terminal. Also, if they didn't launch a terminal before opening their file-browser, this wouldn't mount. I could put it in ~/.profile but I'm not sure how the password interaction would work. They are actually logged into this machine with the same account as they'll use to access samba, so optimally I'd like to avoid the need for the user to re-enter the password.


Try to play with pam_mount it is able to use users password from login process, or krb5 tickets:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.