Server di file 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.

Il server sarà configurato per condividere file con tutti i client presenti nella rete senza richiedere una password. Se l'ambiente richiede controlli di accesso più ristretti, consultare the section called “Rendere sicuro un server di file e di stampa Samba”.

Installazione

The first step is to install the Samba package. From a terminal prompt, enter:

sudo apt-get install samba

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

Configurazione

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

Not all of the available options are included in the default configuration file. See the smb.conf man page or the Samba HOWTO and Reference Guide for more details.

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

    workgroup = EXAMPLE
    ...
    security = user
    

    Il parametro security è più in basso nella sezione [global] e non è commentato per impostazione predefinita. Modificate ESEMPIO per farlo corrispondere all'ambiente reale.

  2. Create una nuova sezione alla fine del file o togliete il commento a uno degli esempi per la cartella da condividere:

    [share]
    comment = Ubuntu File Server Share
    path = /srv/samba/share
    browsable = yes
    guest ok = yes
    read only = no
    create mask = 0755
    
    • comment: una breve descrizione della condivisione. Modificatelo per adattarlo opportunamente.

    • path: il percorso alla cartella da condividere.

      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: enables Windows™ clients to browse the shared directory using WindowsExplorer.

    • guest ok: consente ai client di connettersi alla condivisione senza dover fornire una password.

    • sola lettura: determina se la condivisione è di sola lettura o se sono garantiti anche i privilegi di scrittura. I privilegi di scrittura sono consentiti solo quando il valore è no, come mostrato nell'esempio. Se il valore è , allora l'accesso alla condivisione è in sola lettura.

    • create mask: determina i permessi dei nuovi file creati.

  3. Now that Samba is configured, the directory needs to be created and the permissions changed. From a terminal, enter:

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

    Note

    Il comando -p dice a mkdir di creare l'intera struttura della cartella, se non esiste. Modificate il nome della condivisione per adeguarsi all'ambiente.

  4. Finally, restart the Samba services to enable the new configuration:

    sudo /etc/init.d/samba restart
    

Warning

La configurazione qui sopra fornisce l'accesso completo a tutti i client nella rete locale. Per una configurazione più sicura, consultate the section called “Rendere sicuro un server di file e di stampa 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.

Risorse