So I often use this command to mount a Samba share.

mount -t cifs //ip/share /mnt/backups -o username=user,password=pwd,domain=domain

I want to user a credentials file (with 600 permission) instead of typing in username/password.

Any ideas how this can be done? I've looked around and the only examples I've found are for using a credentials file if I want to auto-mount a Samba share using /etc/fstab.



you must use the argument credentials=

mount -t cifs //ip/share /mnt/backups -o credentials=/path/filename

quoting from man mount.cifs


specifies a file that contains a username and/or password and optionally the name of the workgroup. The format of the file is:

i suggest to create your file under /root/.smbcredentials_sharename with permission 600 as you already said.

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.