Samba is a free software that implements the SMB protocol on Linux and UNIX systems and consists of server and client programs.SMB (Server Messages Block) is a communication protocol for sharing files and printers on a local area network. It provides file and printer sharing services between different computers in the local area network.The SMB protocol is a client/server protocol through which clients can access shared file systems, printers, and other resources on the server.By setting "NetBIOS over TCP/IP", Samba can share resources not only with local area network hosts, but also with computers around the world.
I. Installation Services
1. On the server (172.25.254.103)
1)install
yum search samba
yum install -y samba -client.x86_64 -common-libs.x86_64 -common-tools.x86_64 ##Install samma service
systemctl stop firewalld
systemctl stop iptables ##Close Firewall
setenforce 0
2)Landing Service
smbclient -L //172.25.254.103 ##Logon Services
id student ##Confirm the existence of student users
smbpasswd -a student ##Set Password
smbclient -L //172.25.254.103 -U student ##Log on as a student user
getsebol -a | grep samba
setsebool -P samba_enable_home_dirs on ##Used to share user customizationssambaShare
3)Modify Workgroup Name
//Main profile: /etc/samba/smb.ocnf
vim /etc/samba/smb.conf ##Edit Service Master Profile
workgroup = WESTOS ##Edit Workgroup Name
> server string = Samba Server Version %v
; netbios name = MYSERVER
4)access control
; interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
hosts allow = 172.25.254.89 ##Allow Shared Storage IP
5)Anonymous Access Settings
security = user
passdb backend = tdbsam
map to guest = bad user ##All anonymous users are named guest
[DATA] ##Name of data group
comment = weixin data
path = /westos
guest ok = yes ##Allow anonymous users to log on
; writable = yes ##File Writable
write list = @student ##Writable users in student group
browseable = no ##Hide directories but can be called
valid = student ##Callable User
2. On Client (172.25.254.89)
yum search samba
yum install -y samba -client.x86_64 -common-libs.x86_64 -common-tools.x86_64 ##Install samma service
systemctl stop firewalld
systemctl stop iptables ##Close Firewall
setenforce 0
mount -o username=student,password=123//172.25.254.103/student/mnt/ ##Log on as a student user
df ##Check if mounting was successful
2. Permission Control
1. On the server side
mkdir /westos ##Add Directory
useradd westos ##New Users
smbpasswd -a westso ##Change Password
setfacl -m u :student:rwx /westos ##Read and write to user student
setfacl -m g :student:rwx /westos ##Read and write permissions to users of group student s
usermod -G student westos ##Set user westos group to student
2. On the client side:
mount -o username=westos,password=(Password) //172.25.254.103/DATA /mnt
cd /mnt
touch fie{1..4} ##Test for Read and Write
rm -fr file1
3. Multi-user mounted on client superuser identity
yum install -y cifs-utils
vim /root/smbfile(Any file name)
> username=student
Password=lee
monut -o credentials=/root/smbfile,multiuser,sec=ntlmssp //172.25.254.103(Server)
cd /mnt
ls ##test
//Switch normal user test:
su - kiosk
df
cd /mnt/
ls ##Test, no files can be viewed normally, with permission restrictions
cifscreds add -u westos 172.25.254.103 ##Authenticate westos users under normal users
cd /mnt
ls ##Test, if successful, file visible