How to Install and Configure Samba File Server on Ubuntu 20.04
The Server Message Block (SMB) protocol is implemented https://www.samba.org/by Samba, an opensource package. SMB is a client-server networking protocol used by Microsoft Windows and the OS/2 operating systems for file and printer sharing, as well as other functions. It runs on a Unix system and allows Windows to share files and printers with the Unix host, as well as giving Unix users access to resources shared by Windows. As a result, anyone who has both Windows and Unix systems on their network will find it highly handy.
Samba can be used in the following ways:
- A member of an Active Directory (AD) or NT4 domain
- a self-contained server
- PDC (Primary Domain Controller) or BDC (Backup Domain Controller) for NT4
$ apt update $ apt install samba smb-client cifs-utils
After installing the Samba package, configure the Samba file server on Ubuntu 20.04.
Create a Shared Directory/Folder
Make a directory in which you’ll store files that will be shared. You can make shared folders that are public or private.
$ mkdir /smb-public $ mkdir /smb-private
Configure Samba File Server on Ubuntu 20.04
To edit the Samba configuration file, open it in your favorite editor.
$ vim /etc/samba/smb.conf
Global Samba configuration
Our global Samba configuration is shown below, with comment lines removed.
[global] unix charset = UTF-8 workgroup = WORKGROUP server string = %h server (Samba, Ubuntu) log file = /var/log/samba/log.%m log level = 1 max log size = 1000 logging = file panic action = /usr/share/samba/panic-action %d server role = standalone server obey pam restrictions = yes unix password sync = yes passwd program = /usr/bin/passwd %u passwd chat = *Entersnews*spassword:* %nn *Retypesnews*spassword:* %nn *passwordsupdatedssuccessfully* . pam password change = yes map to guest = bad user usershare allow guests = yes
Public Share Configuration
[sourcecode language=”plain”][publicshare] path = /smb-public writable = yes guest ok = yes guest only = yes force create mode = 775 force directory mode = 775 [/sourcecode]
Private Share Configuration
[sourcecode language=”plain”][privateshare] path = /smb-private writable = yes guest ok = no valid users = @smbinternal force create mode = 770 force directory mode = 770 inherit permissions = yes [/sourcecode]
Create Samba Share User Group
To grant access to the private share, create a smbinternal group and add particular users to it.
$ groupadd smbinternal
Update the permissions
$ chgrp -R smbinternal /smb-private $ chgrp -R smbinternal /smb-public $ chmod 2770 /smb-private $ chmod 2775 /smb-public
Make local accounts for the people you want to have access to the private folder. The shell is not required for the users.
$ useradd -M -s /sbin/nologin demouser $ usermod -aG smbinternal demouser smbpasswd -a demouser smbpasswd -e demouser $ systemctl restart smbd $ systemctl status smbd
Follow us Twitter, Facebook, LinkedIn
Leave a Reply