This article will describe how to install samba and access to home directory and share directory from Windows 10.
IP address of samba server is 192.168.11.67.
Table of Contents
1 Install samba
Install samba with yum.
$ sudo yum install -y samba $ sudo systemctl enable smb nmb
2 Port
Open port with using ervice file of firewall-cmd.
$ sudo firewall-cmd --add-service=samba --permanent $ sudo firewall-cmd --reload
3 SELinux
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.
4 pdbedit
Add user access to samba with pdbedit.
$ sudo pdbedit -a hiroom2 new password: retype new password:
5 /etc/samba/smb.conf
This article show how to share home directory for each user and share directory with multiple user.
Please reboot smbd and nmbd after editing smb.conf.
$ sudo systemctl restart smb nmb
5.1 Share home directory for each user
Share home directory for each user added by pdbedit.
When access hiroom2's home directory "\\192.168.11.67\hiroom2", %s at valid users will be "hiroom".
Only user hiroom2 can access to hiroom2's home directory.
# diff -uprN /etc/samba/smb.conf{.org,} --- /etc/samba/smb.conf.org 2016-05-25 22:45:10.848194665 +0900 +++ /etc/samba/smb.conf 2016-05-25 22:53:23.054571312 +0900 @@ -283,7 +283,7 @@ comment = Home Directories browseable = no writable = yes -; valid users = %S + valid users = %S ; valid users = MYDOMAIN\%S [printers]
5.2 Share directory with multiple user.
Share permission 0777 directory with multiple user adde by pdbedit.
diff -uprN /etc/samba/smb.conf{.org,} --- /etc/samba/smb.conf.org 2016-05-25 23:23:06.053359177 +0900 +++ /etc/samba/smb.conf 2016-05-25 23:24:04.420776634 +0900 @@ -318,3 +318,11 @@ ; writable = yes ; printable = no ; write list = +staff + +[share] + comment = Share directory + path = /var/lib/share + read only = no + guest only = no + guest ok = no
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
6 Access to samba from Windows 10
Access to \\192.168.11.67\hiroom2 with explorer.
Input username and password as same as pdbedit.
Accessed to hiroom2's home directory.
6.1 Map network drive
If mapping network drive, windows 10 will connect to samba automatically when user login.
Move to PC directory in explorer, Select "Map Network drive".
This time, mapping to \\192.168.11.67\share.
Network drive is mapped to samba share directory.