How to create SMB sharing in CENTOS 7

SMB or samba is another type of file sharing protocol in linux.

We will start with installing samba server.

Server > yum -y install samba

Enable and start samba service

Server > systemctl enable samba
Server > systemctl start samba

Samba work using local linux server account. it works for both user account and groups.

we will create a samba group 'Marketing'
Server > groupadd -r marketing

we will then create the share folder for marketing
Server > mkdir -p /smbshare

Change the ownership of the folder and give the permission
Server > chgrp marketing /smbshare
Server > chmod 2775 /smbshare  #this will set SGID bit set, and write is prohibited by others.

Since SELINUX is enable, allow samba_share_t
Server > semanage fcontext -a -t samba_share_t '/smbshare(/.*)?'

Apply the new SELINUX config
Server > restorecon -vvFR /smbshare

We now do the configuration of smb.conf
Server > vi /etc/samba/smb.conf

[global]
workgroup = company
security = user
passwd backend = tdbsam

[sambashare]
path = /smbshare
write list = @marketing

ctrl +x to exit editing

we did not assign any user into the marketing group yet. creating samba user will requrie samba-client
Server > yum -y install samba-client
Server > useradd -s /sbin/nologin -G marketing brian
Server > smbpasswd -a brian

Now, start the smb service
Server > systemctl start smb nmb

Allow firewall for samba service
Server > firewall-cmd --permanent --add-service=samba
Server > firewall-cmd --reload


How to perform multiuser SMB mount.

create a new mountpoing to share for multiuser. mountpoint is the folder that will be mounted as the share folder. all this are setup in client

Desktop > mkdir /mnt/multiuser
Desktop > mount -o multiuser,sec=ntlmssp,username=fred //server/myshare /mnt/multiuser

we will require cifs-util

Desktop > yum -y install cifs-utils
Desktop > cifscred add server

You are now can use the mount as multiuser.

Comments