Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I have a 10.04 desktop machine that I use as a NAS. I have 3 shares on that box which I've been attaching to via mounting at startup in my fstab. I don't like the fact that have my user name and password right out in the open in my fstab. Here's how I'm doing this today..

//                               /media/NAS-Data   smbfs     username=my-name,password=my-password@  0  0  

BTW, am no necessarily married to smbfs, but do want a way to have the credentials cached/saved so I don't have to enter them at startup (if doable)...

share|improve this question

1 Answer 1

up vote 2 down vote accepted

For a samba/CIFS share, you can use a credentials file storing your username/password like this (domain is optional) :


Protected with rights with a chmod 600 (only readable by root)

And in your fstab :

//     /media/NAS-Data   smbfs     credentials=/path/to/your/credential_file  0  0  
share|improve this answer
This worked great. I did find that you have to provide the full path to the credentials file. A relative path didn't work. – Der Wolf Oct 6 at 12:43
@DerWolf : relative paths are often root of evil behaviour ;) . BTW, relative path in your fstab would be complicated to manage; how can you be sure you launch the mount command at the same place everytime ? O:) – Cédric Julien Oct 6 at 12:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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