Add user to samba linux

🛠️ Как добавить пользователя Samba на Linux

Samba – это бесплатная сетевая служба с открытым исходным кодом, работающая по модели клиент-сервер.

Она позволяет обмениваться файлами в операционных системах Windows и Linux/Unix и использует протоколы SMB (Server Messaging Block) и CIFS (Common Internet File system) для беспрепятственного совместного использования ресурсов в сети. Совместное использование Samba считается одним из наиболее эффективных и экономичных способов совместного использования ресурсов в локальной сети – LAN.

Файловый ресурс в Samba называется общим ресурсом samba.

Общий ресурс samba может быть любым – файлом, каталогом или даже принтером.

В сетевой конфигурации клиент посылает серверу Samba запрос на файл, каталог или общий принтер.

В свою очередь, сервер Samba отвечает на эти запросы, отказывая или предоставляя клиенту доступ к запрашиваемым общим ресурсам.

Чтобы получить доступ к общему ресурсу , в Linux необходимо добавить нового пользователя в качестве пользователя samba.

Затем пользователь samba может подключиться к серверу Samba, используя пароль samba, и получить доступ к общим ресурсам.

В этом руководстве мы расскажем вам о процедуре добавления пользователя samba.

Добавление пользователя

Теперь давайте сосредоточимся на том, как добавить нового пользователя в Samba.

Сначала создайте новую учетную запись пользователя, как это делается в любой системе Linux.

В этом примере мы создадим новую учетную запись для пользователя по имени ‘joe’.

Затем добавьте пользователя samba, назначив новому пользователю пароль samba с помощью команды ‘smbpasswd’, как показано на далее:

Вам будет предложено ввести новый пароль samba, а затем подтвердить его, как показано ниже

New SMB password: Retype new SMB password: added user joe.

После создания пользователя samba необходимо добавить его в общий ресурс samba путем редактирования файла samba smb.conf, который является конфигурационным файлом Samba.

Читайте также:  Script linux bash server

Прокрутите и найдите общий ресурс samba, в данном случае ‘documents’, и добавьте пользователя в список допустимых пользователей, как показано в 4-й строке конфигурационного блока ниже.

[documents] comment = Departmental documents share path = /srv/documents valid users = joe public = no writable = yes browsable = yes

Теперь сохраните изменения и выйдите из файла конфигурации.

Чтобы изменения сохранились, перезапустите демон Samba, как показано далее:

sudo systemctl restart smb

Добавление существующего локального пользователя в samba

Если в вашей системе уже есть существующий пользователь, то добавить его в samba довольно просто.

Просто используйте команду ‘smbpasswd’, как показано ниже:

sudo smbpasswd -a existing_user

Затем измените конфигурационный файл и добавьте существующего пользователя в список допустимых пользователей samba, как было показано ранее.

valid users = existing_user

Пункт о добавлении пользователей в Samba версии 4.x

Начиная с Samba версии 4.x и выше, Samba имеет возможность работать в качестве контроллера домена AD.

Вам не нужно иметь стандартного пользователя Linux или Unix в Linux для каждого создаваемого пользователя Samba.

Чтобы добавить пользователей в Samba Active directory, используйте показанную команду:

samba-tool user add username

Удаление пользователя samba

Если вы хотите удалить пользователя Samba из вашей системы, используйте команду ‘smbpasswd’ с опцией -x, за которой следует имя пользователя.

Если вы хотите, вы можете полностью удалить пользователя вместе с домашним каталогом с помощью команды userdel, как показано далее:

Заключение

Мы рассмотрели, как можно добавить и удалить пользователя Samba в системе Linux.

Как было сказано ранее, Samba версии 4.x теперь поддерживает аутентификацию через Active directory, в отличие от предыдущих версий Samba.

Источник

How to Add a Samba User in Linux

Samba is a free and open-source networking service that functions in a client/server networking model. It allows for file sharing across both Windows and Linux/Unix operating systems and leverages the SMB (Server Messaging Block) and the CIFS (Common Internet File system) protocols to seamlessly share resources in a network. Samba sharing is considered one of the most efficient and cost-effective way of sharing resources in a local area network — LAN.

Читайте также:  Linux команда обновления времени

A file share in Samba in referred to as a samba share. A samba share could be anything from a file, a directory, or even a printer. In a network setup, the client sends a request to the Samba server for a file, directory, or a shared printer. In turn, the Samba server responds to these requests by denying or granting the client access to the shared resources requested.

A new user needs to be added as a samba user in Linux to be able to access the samba share. The samba user can then connect to the Samba server using a samba password and access the shared resources. In this tutorial, we will walk you the procedure of adding a samba user

Add a user

Now let’s focus on how to add a new user to Samba. First, create a new user account just as you would in any Linux system. In this example, we will create a new user account for a user called ‘joe‘.

Next, add samba user by assigning a samba password to the new user using the ‘smbpasswd’ command as shown:

You will be prompted to provide a new samba password and later confirm it as shown in the output below

New SMB password: Retype new SMB password: added user joe.

The samba users passwords are stored in a binary file located in /var/lib/samba/private directory. The file is named as passdb.tdb. You won’t be able to view the password — it’s hashed. To manage TDB databases in Linux systems you can use Tdbtool — is a command-line utility.

Once you have created the samba user, you need to add them to the samba share by editing the samba smb.conf file which is Samba’s configuration file. Scroll and locate the samba share, in this case, ‘documents’, and append the user to the list of valid users as shown in the 4th line in the configuration block below.

[documents] comment = Departmental documents share path = /srv/documents valid users = joe public = no writable = yes browsable = yes

Now save the changes and exit the configuration file. For the changes to persist, restart Samba daemon as shown.

sudo systemctl restart smb

Add existing local user to samba

If you already have an existing user on your system, then adding the user to samba is quite straightforward. Simply use the ‘smbpasswd‘ command as shown:

sudo smbpasswd -a existing_user

Then modify the configuration file and add the existing user to the list of valid samba users as shown earlier.

valid users = existing_user

A point on Adding users to Samba version 4.x

Читайте также:  Configure domain in linux

From Samba version 4.x and later, Samba has the ability to run as an AD Domain Controller. You don’t need to have a standard Linux or Unix user in Linux for every Samba user that is created. To add users into Samba Active directory, use the command shown:

samba-tool user add username

Delete samba user

If you want to delete or remove a Samba user from your system, use the ‘smbpasswd‘ command with -x option followed by the username.

If you so desire, you can remove the user completely along with the home directory using the userdel command as shown:

Conclusion

We have covered how you can add and delete a Samba user on a Linux system. As stated earlier, the Samba version 4.x now supports authentication via the Active directory unlike the earlier versions of Samba.

If this resource helped you, let us know your care by a Thanks Tweet. Tweet a thanks

Источник

Оцените статью
Adblock
detector