Fedora 28: Install Samba for SMB server

This article will describe installing samba.

1 Install samba

Install samba package.

$ sudo dnf install -y samba
$ sudo systemctl enable smb nmb

Open port with using service file of firewall-cmd.

$ sudo firewall-cmd --add-service=samba --permanent
$ sudo firewall-cmd --reload

Enable access to home directory without samba_share_t label.

$ sudo setsebool -P samba_enable_home_dirs on

This article will not use other boolean value but below boolean values should be checked.

smbd_anon_write Allow guest write
samba_export_all_ro Allow read without samba_share_t
samba_export_all_rw Allow read/write without samba_share_t

Please see redhat manual for more information.

2 pdbedit

Add user access to samba with pdbedit. This user must be exists in Linux. If user to be added by pdbedit does not exist, you need to add user with useradd.

$ sudo useradd -m <user>

This article adds <user> with pdbedit.

$ sudo pdbedit -a <user>
new password:
retype new password:

-t option reads password from stdout.

$ yes "${PASSWD}" | sudo pdbedit -a <user> -t

3 /etc/samba/smb.conf

This article show how to share home directory for each user and share directory with multiple user.

Please reboot smb and nmb after editing smb.conf.

$ sudo systemctl restart smb nmb

3.1 Share home directory for each user

Samba provides /home/<user> sharing to <user> added by pdbedit. This /home/<user> can be accessed by <user> only (The following %S is set to <user> when accessing to Samba).

valid users = %S

Home directory can be shared by default. If you need to disable it, comment out "[homes]" section all.

Access to the following URL from client.

\\<server>\<user>

3.2 Share directory with multiple user.

Share permission 0777 directory with multiple user adde by pdbedit.

$ cat <<EOF | sudo tee -a /etc/samba/smb.conf
[share]
   comment = Share directory
   path = /var/lib/share
   read only = no
   guest only = no
   guest ok = no
   share modes = yes
EOF

Change /var/lib/share's permission to 0777. Add samba_share_t label to /var/lib/share.

$ sudo mkdir /var/lib/share
$ sudo chmod 0777 /var/lib/share
$ sudo chcon -R -t samba_share_t /var/lib/share

Access to the following URL from client.

\\<server>\share