10

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 use 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.

Thanks

1 Answer 1

20

you must use the argument credentials=

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

quoting from man mount.cifs

credentials=filename

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

username=value
password=value
domain=value

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

Make sure NOT to have spaces around the = or you will get permission denied errors as the values are not correctly taken into account.

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.