This is an old revision of the document!
Table of Contents
Create Windows SMB Network Share with samba under Ubuntu
Samba is a free software re-implementation of the SMB/CIFS networking protocol. Samba provides file and print services for various Microsoft Windows clients and can integrate with a Microsoft Windows Server domain.
Setup SMB share
Installation
First install the samba package:
$ sudo apt install samba
The configuration files are located at /etc/samba/smb.conf
User creation
Next we need to add a SMB user, used to sign-in to the SMB share. These user credentials need to match the existing Linux user's specifications exactly.
Creating a SMB user is provided by the smbpasswd command, followed by the -a flag, which specifies that we want to add a new user. Remember, the name and password needs to match the Linux user exactly.
$ sudo smbpasswd -a <user>
If you want to create multiple SMB users, and hence multiple corresponding Linux users, it is wise to disable certain permissions for those users within Linux.
The /user/sbin/nologin shell disables SSH access to that user.
$ sudo adduser <user2> --shell /usr/sbin/nologin $ sudo smbpasswd -a <user2>
Configuration
As mentioned further above, the configuration files are located at /etc/samba/smb.conf
These this file is used to configure the relevant shares and permissions.
Adding a simple share, with only user2 having access to it, would require this configuration at the bottom of the config file:
[User Two Files] comment = Second User Files valid users = user2 public = yes writable = yes browsable = yes path = "/path/to/share"
Starting the service
Samba includes a systemd service by default called smbd.service
Once your configurations are complete, you can start the SMB server:
$ sudo systemctl start smbd $ sudo systemctl enable smbd