Difference between revisions of "Mounting samba shares from a unix client"

 
(created Mounting samba shares from a unix client)
Line 1: Line 1:
 
==Mounting samba shares from a unix client==
 
==Mounting samba shares from a unix client==
 
+
===General description===
 
Using a share from a samba server within a unix filesystem depends on a lot of single components. You need at least the smbfs (which is no longer maintained) or the modern cifs kernel modules. Although many documentation says to use the smbfs, it has many restrictions and the cifs should be favoured. That said, I'll describe only the cifs module in this document.
 
Using a share from a samba server within a unix filesystem depends on a lot of single components. You need at least the smbfs (which is no longer maintained) or the modern cifs kernel modules. Although many documentation says to use the smbfs, it has many restrictions and the cifs should be favoured. That said, I'll describe only the cifs module in this document.
  
Line 14: Line 14:
 
''mountpoint'' must be a directory elsewhere in the filesystemm which must exist.
 
''mountpoint'' must be a directory elsewhere in the filesystemm which must exist.
  
TODO: explain the options for mount -t cifs as described in man mount.cifs
+
===Common mount.cifs options===
 +
Now an explaination of the options for mount -t cifs as described in man mount.cifs
 +
''mount.cifs'' takes a lot of options, some of them are really confusing. I'll try to mention the most important here.
 +
 
 +
* ''user=<user>'' or ''username=<user>'': Thats the user <user> which is used to authenticate against the server. If this is not given, then the environment variable USER is used. This option can also take the form  "user%password"  or  "workgroup/user"  or  "workgroup/user%password" to allow the password and workgroup to be specified as part of the username.
 +
* ''pass=<password>'' or ''password=<password>'': specifies the CIFS password. If this option is not given then the environment variable PASSWD is used. If the password is not specified directly or indirectly via an argument to  mount  mount.cifs will prompt for a password, unless the guest option is specified.
 +
* ''credentials=<filename>'':specifies a file that contains a username and/or password. This is preferred over having passwords in plaintext in a shared file, such as /etc/fstab. Be  sure to protect any credentials file properly. The format of the file is:
 +
username=value
 +
password=value
 +
* ''uid=<uid-spec>'': sets  the  uid  that  will own all files on the mounted filesystem. It may be specified as either a username or a numeric uid. This parameter is ignored when the target server supports the CIFS Unix extensions (which samba does per default unless you disable it).
 +
* ''gid=<group-spec>'': sets the gid that will own all files on the mounted filesystem. It may be specified as either a groupname or a numeric gid. This parameter is ignored when the target server supports the CIFS Unix extensions.
 +
* ''domain=<domain|workgroup>'': sets the domain (workgroup) of the user
 +
* ''ip=<ip-addr>'': sets the destination host or IP address.
 +
* ''guest'': mount the share as guest and don't prompt for a password.
 +
 
 +
There are other options but they are not that important to be usefull beside performance and really specific things.
  
 +
===NetBios name resolution with WINS===
 
TODO: explain the name resolution with libnss_wins.so
 
TODO: explain the name resolution with libnss_wins.so
  
 +
===Step by Step list to get it working===
 
TODO: make a step by step list to solve most of the problems
 
TODO: make a step by step list to solve most of the problems
  
 +
===Mounting shares at logon time===
 
If you want to automatically mount shares at user logon time the only way I found is doing it with the pam_mount module. It is the only way to do an authenticated mount without requiring the user to store the password in a file or entering it on a terminal.
 
If you want to automatically mount shares at user logon time the only way I found is doing it with the pam_mount module. It is the only way to do an authenticated mount without requiring the user to store the password in a file or entering it on a terminal.
 +
 +
----
 +
--[[User:Rcsu|Rcsu]] 21:40, 4 March 2006 (UTC)

Revision as of 21:42, 4 March 2006

Mounting samba shares from a unix client

General description

Using a share from a samba server within a unix filesystem depends on a lot of single components. You need at least the smbfs (which is no longer maintained) or the modern cifs kernel modules. Although many documentation says to use the smbfs, it has many restrictions and the cifs should be favoured. That said, I'll describe only the cifs module in this document.

Since the cifs filesystem is included in the standard Linux kernel, it is simple to build either as module or built in. You need to load it prior to mount a share or let modprobe load it via modprobe.conf.

The basic mount command is mount -t cifs //<server>/<share> <mountpoint>. Each component needs its own attention.

The mount utility calls a mount helper, usually mount.cifs and that in turn calls the utility smbmount. The mount helper mount.cifs is the user space helper and needed to do the authentication.

To resolve the <server> to a ip address, you need either a DNS server which knows the ip address or your client needs the nss module wins. It is a shared library which must be in the path of your ldd. Usually under /usr/lib. You also have to add the wins option to hosts in your /etc/nsswitch.conf.

mountpoint must be a directory elsewhere in the filesystemm which must exist.

Common mount.cifs options

Now an explaination of the options for mount -t cifs as described in man mount.cifs mount.cifs takes a lot of options, some of them are really confusing. I'll try to mention the most important here.

  • user=<user> or username=<user>: Thats the user <user> which is used to authenticate against the server. If this is not given, then the environment variable USER is used. This option can also take the form "user%password" or "workgroup/user" or "workgroup/user%password" to allow the password and workgroup to be specified as part of the username.
  • pass=<password> or password=<password>: specifies the CIFS password. If this option is not given then the environment variable PASSWD is used. If the password is not specified directly or indirectly via an argument to mount mount.cifs will prompt for a password, unless the guest option is specified.
  • credentials=<filename>:specifies a file that contains a username and/or password. This is preferred over having passwords in plaintext in a shared file, such as /etc/fstab. Be sure to protect any credentials file properly. The format of the file is:
username=value
password=value
  • uid=<uid-spec>: sets the uid that will own all files on the mounted filesystem. It may be specified as either a username or a numeric uid. This parameter is ignored when the target server supports the CIFS Unix extensions (which samba does per default unless you disable it).
  • gid=<group-spec>: sets the gid that will own all files on the mounted filesystem. It may be specified as either a groupname or a numeric gid. This parameter is ignored when the target server supports the CIFS Unix extensions.
  • domain=<domain|workgroup>: sets the domain (workgroup) of the user
  • ip=<ip-addr>: sets the destination host or IP address.
  • guest: mount the share as guest and don't prompt for a password.

There are other options but they are not that important to be usefull beside performance and really specific things.

NetBios name resolution with WINS

TODO: explain the name resolution with libnss_wins.so

Step by Step list to get it working

TODO: make a step by step list to solve most of the problems

Mounting shares at logon time

If you want to automatically mount shares at user logon time the only way I found is doing it with the pam_mount module. It is the only way to do an authenticated mount without requiring the user to store the password in a file or entering it on a terminal.


--Rcsu 21:40, 4 March 2006 (UTC)