Proper way to mount NAS shares w/o password in fstab?

6,371

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

username=my_username
password=my_password
domain=my_domain

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

And in your fstab :

//192.168.0.40/Data     /media/NAS-Data   smbfs     credentials=/path/to/your/credential_file  0  0  
Share:
6,371

Related videos on Youtube

Kendor
Author by

Kendor

Updated on September 18, 2022

Comments

  • Kendor
    Kendor over 1 year

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

    //192.168.0.40/Data                               /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)...

  • Der Wolf
    Der Wolf over 8 years
    This worked great. I did find that you have to provide the full path to the credentials file. A relative path didn't work.
  • Bebbolin
    Bebbolin over 8 years
    @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:)