Samba on Linux

by Peter Jones / April 16, 2008

These notes outline using the Samba client tools to mount a SMB share on a Linux server.

Installing Samba on RHEL 4

Download one of the RPM packages from Enterprise Samba. You can inspect the contents of the package, and then install the package via the following commands:

$ rpm -q --filesbypkg -p <file-name>
$ rpm -i -p <file-name>

Create an Authentication File

Instead of passing share authentication credentials to smbclient and mount.cifs all the time, you should create a file somewhere that looks like this:

username=Administrator
password=SomeLamePassword
domain=DomainsAreDumb

Note: It appears that smbclient can handle spaces in the authorization file, as does smbmount, but mount.cifs doesn't strip them out, which will lead to an authorization error, and a not so helpful "Permission denied" error message.

You can now use smbclient like so:

$ smbclient //server/share -A /path/to/authentication/file

Note: Make sure your authentication file is not world-readable.

Mounting a SMB/CIFS Share

Using mount(8):

$ mount -t cifs -ocredentials=/authfile,rw //server/share /mnt

You can also use /etc/fstab to make the mount automatic:

//server/share	/mnt	cifs	credentials=/authfile,rw 0 0

Note: When using the cifs mount type, the file responsible for doing the actual mount is /sbin/mount.cifs. Likewise, when using smbfs, the file invoked is /sbin/mount.smbfs.

Troubleshooting

Mount with the --verbose flag:

$ mount -t cifs //server/share /mnt --verbose -ocredentials=/authfile,rw

Tags: linux samba smb cifs