Файловый сервер Samba

Один из наиболее распространённых способов объединить в сеть Kubuntu и компьютеры Windows - настройка Samba в качестве файлового сервера. Этот раздел посвящён настройке сервера Samba для обмена файлами с клиентами Windows.

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 “Securing a Samba File and Print Server”

Установка

Первый шаг - установка пакета samba. Введите в терминале:

sudo apt-get install samba

Вот и все, что нужно сделать. Сервер Samba готов для настройки для совместного использования файлов.

Настройка

Основной файл настройки Samba находится в /etc/samba/smb.conf. Файл настроек по умолчанию включает в себя значительное количество комментариев, для документирования различных параметров конфигурации.

Note

Не все доступные опции включены в файл настроек по умолчанию. Смотрите страницу руководства man для файла smb.conf или посетите Коллекцию Samba HOWTO для получения дополнительной информации.

  1. Измените следующее значение раздела [global] файла /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: — путь к каталогу, к которому будет открыт доступ

      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: позволяет Windows-клиентам просматривать какталог, к которому открыт общий доступ, с помощью Windows Explorer.

    • guest ok: позволяет клиентам подключаться к ресурсу без ввода пароля.

    • read only: determines if the share is read only or if write privileges are granted. Write privileges are allowed only when the value is no, as is seen in this example. If the value is yes, then access to the share is read only.

    • create mask: determines the permissions new files will have when created.

  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

    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. Finally, restart the samba services to enable the new configuration:

    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 “Securing a Samba File and Print Server”.

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.

Resources