SliTaz GNU/Linux official and community documentation wiki.
.png
Translations of this page:

Source originale de documentation avant traduction : http://doc.slitaz.org/en:guides:samba

Qu'est-ce que Samba ?

Samba ou la suite SMB est une collection de logiciels permettant la communication réseau entre les dossiers avec Windows. Le nom Samba est une variant de SMB, qui est le protocole utilisé par Windows pour que les dossier en réseau puissent être accessibles. La première version de Samba date de 1992 et beaucoup de development a été mis en place durant ces années. Il en a résulté une grande stabilité et fiabilité du code. Le projet Samba possède aussi son propre site web, ou d'avantage d'informations peuvent être trouvées

A quoi cela sert ?

Avec Samba, votre machine Slitaz est capable d'acceder aux fichiers partagés windows. Il est aussi possible de fournir un partage Windows depuis la machine Linux/Slitaz, et de permettre aux machines windows d'y acceder comme si c'était une machine windows qui les rendait accessible.

Comment cela fonctionne ?

La suite Samba contient 2 composants. Une implementation server et client. For example if you have a storage device at home, it will most likely support SMB/CIFS. This means you can use the Samba client to access it from Linux.

Nous allons commencer par installer la partie client (smbclient) puis la partie permettant la lecture du systeme de fichier avec le protocole smb (smbfs) :

# tazpkg get-install smbclient
# tazpkg get-install smbfs

SUITE A COMPLETER

The tazpkg manager will take care of the dependencies so probably you will see a lot more packages being installed. Once this is completed, you can view the shares on your Windows server or storage system with:

# smbclient -L nas
Enter User's password: ****

This will provide a list of the shares available on \\nas. The result should look similar to the example below:

Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.3-31a.osstech]

	Sharename       Type      Comment
	---------       ----      -------
	IPC$            IPC       IPC Service ("My NAS")
	webaxs          Disk      
	share           Disk      LinkStation folder
	info            Disk      LinkStation Utilities
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.3-31a.osstech]

	Server               Comment
	---------            -------
	NAS                  My NAS

	Workgroup            Master
	---------            -------
	WORKGROUP            NAS
# 

From the above example, we are interested in access to Sharename 'share'. Although not strictly required, it is recommended to add the server name to /etc/hosts for name resolution when it has a fixed ip address. Because we are running on Linux we need to 'escape' the backslashes in the UNC path, effectively needing twice the number of them. Accessing \share on \\nas goes like this:

# smbclient \\\\nas\\share
Enter User's password: ****
smb: \> 

At the prompt you can issue ftp-style commands to browse the file system and read/write files. Typing help gives you a summary of the options:

smb: \> help
?              allinfo        altname        archive        blocksize      
cancel         case_sensitive cd             chmod          chown          
close          del            dir            du             echo           
exit           get            getfacl        hardlink       help           
history        iosize         lcd            link           lock           
lowercase      ls             l              mask           md             
mget           mkdir          more           mput           newer          
open           posix          posix_encrypt  posix_open     posix_mkdir    
posix_rmdir    posix_unlink   print          prompt         put            
pwd            q              queue          quit           readlink       
rd             recurse        reget          rename         reput          
rm             rmdir          showacls       setmode        stat           
symlink        tar            tarmode        translate      unlock         
volume         vuid           wdel           logon          listconnect    
showconnect    ..             !              
smb: \> quit
#

Fortunately you can also access a Windows share by mounting it on your box like this:

First create the mount point on your slitaz box: 
# mkdir /nas
#

Then issue the mount command:

# mount.cifs \\\\nas\\share /nas -o user=admin
Password: ******
#

An alternative method is like this:

# mount //nas/share /nas
Password: ******
#

If there is no access-denied-message in reply to the password, it means the share is mounted and can be accessed from your box. That's basically it!

The password must be the admin password for your storage device. This may not work when you have enabled user-based security. In some cases the mount may be read-only.

Many of the problems with Samba are caused by a lack of understanding the Windows security mechanism. In its basic version, which is still used most of the time, this is user-based security so you will need a valid windows user account to access the file share. When in trouble, verify the access is working from a windows machine and use the same credentials under Linux.

Running a Samba Server on Slitaz

If you need to set up a Windows file server but you don't want to invest in over-the-top hardware and Windows licenses, Samba is the way to go. Of course you can use Slitaz as the Linux platform to run the server. With this solution you will also benefit from the superior stability of the Linux OS. One of the problems of a Samba administrator is that he sometimes forgets the details of his installation because everything simply keeps on running once it has been set up properly. This is one of the reasons why Linux people need documentation anyway. ;-)

To install the server component of Samba, install the following package:

# tazpkg -gi samba

In order to make the user experience even more seamless, it is recommended to keep the accounts synchronized. This means the users should have the same username & password on their windows box as they are using on the Samba server. Explanation: When Windows connects to a share, it always attempts to authenticate using the credentials of the user that requests the access. If there is no match, the user is prompted for a username/password but when they are the same, the share is accessed without any further prompting.

The procedure to add a user to your samba server:

First add Linux user using the adduser command.

# adduser smbuser01
Changing password for smbuser01
New password: 
Retype password: 
Password for smbuser01 changed by root

Then add the same user name to Samba using: smbpasswd -a

# smbpasswd -a smbuser01
New SMB password:
Retype new SMB password:
Added user smbuser01.
# 

Use: smbpasswd -h to view the options.

The file shares and printers you want to allow your Windows clients access to can be defined in the Samba configuration file which is: /etc/samba/smb.conf

There are countless options to configure here like login scripts, home folders etcetera. Elaborating on all of them would be way beyond the scope of this guide.

A good place to start is http://www.tldp.org/HOWTO/SMB-HOWTO-2.html which provides a comprehensive overview of Samba but there are many other sites on the web with virtually the same content. As Samba has been around for over two decades, almost all things have already been tried, done and extensively documented in the process. Just search the web. You may encounter some negative comments as well but these are generally posted by people who made some basic mistake or have been the victim of some undocumented change in Windows. Don't let yourself be discouraged by this. Samba is Alive and Kicking and when you know how to search for them, you can be sure to find detailed answers to all issues you may encounter while setting up your own server.

 
fr/guides/samba2.txt · Last modified: 2016/12/01 13:21 by telvid