Both sides previous revisionPrevious revision | |
slackware:samba [2018/11/02 20:16] – Small fixes to modernize the instructions. alien | slackware:samba [2018/11/21 21:07] (current) – CIFS is used nowadays by smbmount alien |
---|
| |
On a linux client computer, it is the ''smbmount'' command that lets you mount a Samba (or a Windows!) share on the local filesystem. You can run the command manually in a console like this: <code> | On a linux client computer, it is the ''smbmount'' command that lets you mount a Samba (or a Windows!) share on the local filesystem. You can run the command manually in a console like this: <code> |
mount -t smbfs //192.168.0.1/public /mnt/samba/bob/public -o rw,uid=0,gid=10,fmask=664,dmask=775 -U <some_special_user> | mount -t cifs //192.168.0.1/public /mnt/samba/bob/public -o rw,uid=0,gid=10,fmask=664,dmask=775 -U <some_special_user> |
</code> which will mount the share called //public// on our server called //bob// which has the IP Address ''192.168.0.1'' in this example. The mountpoint ''/mnt/samba/bob/public'' must of course be created as a directory before. I chose ''/mnt/samba/bob/public'' arbitrarily, I like looking at the mount point's name and be able to guess what it is all about. You are of course free to take another mount point.\\ The command mounts the share as user //<some_special_user>// and it's up to you who that user account is, as long as it has the necessary access rights to the share. If the account has a password associated with it, you will be asked for it.\\ | </code> which will mount the share called //public// on our server called //bob// which has the IP Address ''192.168.0.1'' in this example. The mountpoint ''/mnt/samba/bob/public'' must of course be created as a directory before. I chose ''/mnt/samba/bob/public'' arbitrarily, I like looking at the mount point's name and be able to guess what it is all about. You are of course free to take another mount point.\\ The command mounts the share as user //<some_special_user>// and it's up to you who that user account is, as long as it has the necessary access rights to the share. If the account has a password associated with it, you will be asked for it.\\ |
The //-o rw,uid=0,gid=10,fmask=664,dmask=775// part means that the remote share will be mounted locally read/write, seemingly owned by user root:wheel (uid=0, gid=10) and with file- and directory masks that make the share's files and directories read/only for non-root, non-[[linux:security#wheel | wheel users]]. Having to type all this in order to mount the share is a tedious effort, so we take the easy way and add the following line to ''/etc/fstab'': <code> | The //-o rw,uid=0,gid=10,fmask=664,dmask=775// part means that the remote share will be mounted locally read/write, seemingly owned by user root:wheel (uid=0, gid=10) and with file- and directory masks that make the share's files and directories read/only for non-root, non-[[linux:security#wheel | wheel users]]. Having to type all this in order to mount the share is a tedious effort, so we take the easy way and add the following line to ''/etc/fstab'': <code> |
//192.168.0.1/public /mnt/samba/bob/public smbfs rw,uid=0,gid=10,fmask=664,dmask=775,credentials=/etc/bob.cred 0 0 | //192.168.0.1/public /mnt/samba/bob/public cifs rw,uid=0,gid=10,fmask=664,dmask=775,credentials=/etc/bob.cred 0 0 |
</code> We store the username and password that we need for gaining access to the //public// share, in a file called ''/etc/bob.cred'' which we protect from prying eyes by removing read access for all but the root user: <code> | </code> We store the username and password that we need for gaining access to the //public// share, in a file called ''/etc/bob.cred'' which we protect from prying eyes by removing read access for all but the root user: <code> |
chmod 600 /etc/bob.cred | chmod 600 /etc/bob.cred |
password = <the_secret_word> | password = <the_secret_word> |
</code> Having this in our client computer's ''/etc/fstab'' will cause the samba share to be automatically mounted when the computer boots. | </code> Having this in our client computer's ''/etc/fstab'' will cause the samba share to be automatically mounted when the computer boots. |
| |
| <note tip>The older "''smbfs''" kernel module is outdated while the "''cifs''" kernel driver is well-maintained and supports higher versions of the SMB protocol than ''smbfs''. Samba implements the CIFS protocol (a dialect of the SMB protocol) and it supports SMB2 and parts of the SMB3 protocol extensions.</note> |
| |
| <note tip>The default CIFS protocol changed from SMB 1.0 to SMB 3.0 in kernel 4.13. If you are running an older Samba server and try to mount its shares on a recent Linux computer this changed default breaks the mounts. In order to force the mount to use SMB 1.0 you need to add "''vers=1.0''" to the mount options</note> |
| |
=== Mixing protected and passwordless shares === | === Mixing protected and passwordless shares === |