Samba Server Installation and Configuration on CentOS/Rhel 7.x

Samba Server Installation and Configuration on CentOS/Rhel 7.x

Now we will install these packages at the CentOS/Rhel 7.x server :

#yum install samba samba-common samba-client

Now create a directory for sharing :

#mkdir -p /samba_shared

Change the permission of the folder as follow :

#chmod -R 777 /samba_shared

Add a new group and user as follows :

#groupadd samba
#useradd SambaTest

Change the owner, group and permission of shared directory :

#usermod -aG samba SambaTest
#chown -R SambaTest:samba /samba_shared
#chmod -R 777 /samba_shared

Add the Samba service in firewall as follows :

#firewall-cmd --permanent --add-service=samba
#firewall-cmd --permanent --reload

Now to configure samba edit the file :

#vi /etc/samba/smb.conf

Add the following line in above samba configuration file :

[samba_shared]
path = /samba_shared
browsable =yes
writeable =yes
public =no
valid users = @samba
write list = @samba

Add and Enable Samba Users as follows :

#smbpasswd -a SambaTest
#smbpasswd -e SambaTest

Next we need to start the Samba Service as follows :

#systemctl start smb

Now enable these Services to start at boot menu :

#systemctl enable smb

Samba Client Installation and Configuration on CentOS/Rhel 7.x

Mounting the Samba Share in Linux machine :

#smbclient –L 192.168.100.2 -U SambaTest
#mount //192.168.100.2/samba_shared /mnt -o username=SambaTest

The credentials hidden file have with “600” permission /samba/.credential :

username=SambaTest
password=Natsav

Permanent mounting add the following line into /etc/fstab file :

//192.168.100.2/samba_shared /mnt cifs credentials=/samba/.credential,defaults 0 0

Leave a Reply

Your email address will not be published. Required fields are marked *