HOWTO: mount samba shares in fstab using a credential file

Hello,

If you want to mount share files using samba but you don’t want to put the username or password on fstab file, you could use an external file, this is useful if you want to increase a little security since fstab usually is world readable.

Using /etc/fstab

# insecure and common usage
//share/dir /mnt/myshare cifs username=user,password=pass

# more secure usage
mkdir /path/securedir
chmod 0700 /path/securedir
chown root /path/securedir
//share/dir /mt/myshare cifs credentials=/path/securedir/fileshare

cat /path/securedir/fileshare
username=yourusername
password=youpass

As you can see, it’s easy and increase a little security if more users can access in you machine.

of course you can use smbmount too:

smbmount //share/dir /mnt/myshare -o credentials=/path/securedir/fileshare

See you!

9 thoughts on “HOWTO: mount samba shares in fstab using a credential file

  1. Great, I don’t want my pass in fstab!
    THing is thoug that dmesg|tail still tells me no username is specified after a failure.

  2. You may need to install cifs-utils in order to use the credentials file – this would install /sbin/mount.cifs which is required for reading the credentials file….

  3. […] . data.txt echo "$name" echo "$password" I hope you realize that having/storing sensitive password information directly in a script or readable text file is a bit of a security risk. However, some systems, such as samba share mounting, already have a "credentials" option that operates pretty much the same way, since it's safer than including them directly in globally available files like fstab. https://anothersysadmin.wordpress.com…edential-file/ […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s