Páginas

Tuesday, 8 July 2014

Mounting CIFS in Linux (Suse)



CIFS is a network protocol which is used for providing shared access to files, printers, serial ports, and miscellaneous communications between nodes on a network.
It is a public or open variation of the Server Message Block Protocol developed and used by Microsoft. Like the SMB protocol, CIFS runs at a higher level than and uses the Internet's TCP/IP protocol.

You can use mount or mount.cifs to have access to a CIFS share with the following syntax

mount -t //servername/share /mountpoint -o username=smbuser,password=smbpass, domain=smb.com,uid=smblinux,gid=smbgroup
 
I will explain the options that I have used
username is the windows user which has been given permissions in the share
password well, it doesn't need explanation
domain is the domain which the user belongs to
uid is the linux user that will own all files or directories on the mounted filesystem
gid is the linux group that will own all files or directories on the mounted filesystem


You can make this mountpoint permanent by adding the line into the /etc/fstab file but if for security reasons, you want to hide the password you can do it in the following way. Create a file and add the credentials there. For instance,

/home/smblinux/.password (set the necessary permissions so only root can read this file)

username=smbuser
password=smbpass
domain=smb.com

And then add the following line to /etc/fstbab
//servername/share /mountpoint cifs credentials=/home/smblinux/.password,uid=smblinux,gid=smbgroup 0 0

 
If you want to check the shares that one server has, you can use the smbclient command

smbclient -N -L hostname