Skip to content

HOWTO: mount samba shares in fstab using a credential file

by on December 17, 2007


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

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!

From → Linux, Tips, Unix

  1. com va tot tros de marica?

    et trobo a faltar tontu! siiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii! jejejejeje

    1 abra├žada

  2. Good tip :)

    Many thanks…..

  3. Schop permalink

    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.

  4. Michel permalink

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

Trackbacks & Pingbacks

  1. storing a password in an environment variable
  2. How to fetch data from file

Leave a Reply

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

You are commenting using your 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


Get every new post delivered to your Inbox.

%d bloggers like this: