Servidor de fichièrs Samba

One of the most common ways to network Kubuntu and Windows computers is to configure Samba as a File Server. This section covers setting up a Samba server to share files with Windows clients.

The server will be configured to share files with any client on the network without prompting for a password. If the environment requires stricter Access Controls, see the section called “Securizar un servidor de fichièrs e d'estampatge Samba”

Installacion

La primièra etapa consistís a installar lo paquet samba. Dins un terminal picatz :

sudo apt-get install samba

That's all there is to it. Samba is ready to be configured for file sharing.

Configuracion

The main Samba configuration file is located in /etc/samba/smb.conf. The default configuration file has a significant number of comments in order to document various configuration directives.

Note

Lo fichièr de configuracion conten pas totas las opcions disponiblas. Consultatz la pagina man de smb.conf o Samba HOWTO Colleccion (en)ulink> per mai de detalhs.

  1. Edit the following key/value pairs in the [global] section of /etc/samba/smb.conf:

    workgroup = EXAMPLE
    ...
    security = user
    

    The security parameter is farther down in the [global] section, and is commented out by default. Change EXAMPLE to match the actual environment.

  2. Create a new section at the bottom of the file, or uncomment one of the examples for the directory to be shared:

    [share]
    comment = Ubuntu File Server Share
    path = /srv/samba/share
    browsable = yes
    guest ok = yes
    read only = no
    create mask = 0755
    
    • comment: a short description of the share. Adjust to fit as appropriate.

    • path : l'emplaçament del dorsièr de partejar.

      This example uses /srv/samba/sharename because, according to the Filesystem Hierarchy Standard (FHS), /srv is where site-specific data should be served. Technically Samba shares can be placed anywhere on the filesystem as long as the permissions are correct, but adhering to standards is recommended.

    • browsable : autoriza los clients Windows a percórrer lo repertòri partejat en utilizant l'explorador de fichièrs de Windows.

    • guest ok : permet als clients de se connectar al repertòri partejat sens provesir de senhal.

    • read only : determina se lo partiment es en lectura sola o se los privilègis en escritura son acordats. Los dreches d'escritura son acordats solament se la valor es no. Coma òm lo veu dins aqueste exemple, se la valor es yes, alara l'accès al partimente es en lectura sola.

    • create mask : determina las permissions dels fichièrs creats novèlament.

  3. Ara que Samba es configurat, lo repertòri deu èsser creat e las permissions modificadas. Dempuèi un terminal, picatz :

    sudo mkdir -p /srv/samba/share
    sudo chown nobody.nogroup /srv/samba/share/
    

    Note

    The -p switch tells mkdir to create the entire directory tree if it doesn't exist. Change the share name to fit the environment.

  4. Per acabar, reaviatz los servicis samba per activar la configuracion novèla :

    sudo /etc/init.d/samba restart
    

Warning

The above configuration gives all access to any client on the local network. For a more secure configuration, see the section called “Securizar un servidor de fichièrs e d'estampatge Samba”.

From a Windows client, it should now be possible to browse to the Kubuntu file server and see the shared directory. To check that everything is working, try creating a directory from Windows.

To create additional shares, simply create new [dir] sections in /etc/samba/smb.conf, and restart Samba. Make sure that the directory to be shared actually exists and that the permissions are correct.

Ressorsas