Configuring and Accessing Samba on CentOS/RHEL7

Anju
1 min readApr 5, 2021

--

Building samba server:

sudo yum install samba samba-clientsystemctl enable smb
systemctl enable nmb
systemctl start smb
systemctl start nmb
#Update the samba config file
vi /etc/samba/smb.conf
#Append this [test]
path = /download
valid users = sambauser
browseable = yes
hosts allow = 192.150.
#test the configurations
testparm
#Create dir for share
mkdir download
#restart the services
systemctl restart smb nmb
#Add user for to access samba share
useradd sambauser
passwd sambauser
#Add same user for sambadb
smbpasswd -a sambauser
#Check if share is visible
smbclient -L //<samba server ip> -U sambauser
smbclient //<samba server ip>/<samba-share-name> -U sambauser

Accessing the share from client:

yum install cifs-utils#Add the same user for to access samba share
useradd sambauser
passwd sambauser
#create a dir to mount
mkdir download_mnt
# mount it
mount -t cifs -o username=sambauser //<samba server ip>/<samba-share-name> /download_mnt

Note:

samba-share-name is the same name you specify in the config file in [] brackets not the dir nameYou can mount it as a persistent fs by updating fstab 

--

--

Anju
Anju

Written by Anju

A DevOps engineer who loves automating everything (almost), exploring new places, and finding peace in nature. Always looking for the next adventure!

No responses yet