Centos7 builds Samba file sharing service

Samba is a free software that implements SMB protocol for file sharing and printer sharing between different operating systems (Windows, Linux). The SMB protocol is a client / server protocol through which clients can access shared files and printer shared resources on the server. It is mainly used on local area networks, and can also share resources with computers in the Internet by setting "NetBIOS over TCP / IP".

SMB protocol: TCP 139 port CIFS protocol: TCP 445 port

  • Samba installation

systemctl stop firewalld
systemctl disable firewalld
setenforce 0

yum -y install samba
  • Create the corresponding directory and authorize it, add user groups and users

#Create the corresponding directory and store all files in the / home / smb directory 

  mkdir / home / smb 
  cd / home / smb
  mkdir share publish admin1 admin2 user1 user2 #Configure 


the permissions and ownership of the relevant directory

  chmod -R 777 / home / smb


 #Create users and user groups Add ordinary users to the group_user group, and administrators to the group_admin group. 
    groupadd group_admin 
    groupadd group_user 

    useradd   -g group_admin1 -d / home / smb / admin1 -s / sbin / nologin admin1 
    useradd   -g group_user -d / home / smb / user2 -s / sbin / nologin user2 The 

above is to add admin1 and user2 separately group_admin, group_user administrator group, ordinary user group. So ······ 
# Note: - G to add users belonging group 

     -G specifies a plurality of extension or user groups

      - D home directory location specified

      -s used SHELL, / sbin / nologin, blocking the user login To the system
  • Add Samba user and set password

  smbpasswd- a admin1 
  New SMB password: add the admin1 password here 

  Retype new SMB password: repeat secret 

  and so on to add other user passwords
  • Edit the configuration file smb.conf

[global]
    workgroup = SAMBA
    security = user

    passdb backend = tdbsam

    printing = cups
    printcap name = cups
    load printers = yes
    cups options = raw

[homes]
    comment = Home Directories
    valid users = %S, %D%w%S
    browseable = No
    read only = No
    inherit acls = Yes

[printers]
    comment = All Printers
    path = /var/tmp
    printable = Yes
    create mask = 0600
    browseable = No

[print$]
    comment = Printer Drivers
    path = /var/lib/samba/drivers
    write list = @printadmin root
    force group = @printadmin
    create mask = 0664
    directory mask = 0775
[share]
    comment=Share
    path=/home/smb/share
    readonly=yes
    write list = @group_user,@group_admin
    create mask = 0775
    directory mask = 0775

[publish]
    comment=Publish
    path=/home/smb/publish
    readonly=yes
    write list =@group_admin
    create mask = 0775
    directory mask = 0775

[admin1]
    comment=admin1
    path=/home/smb/admin1
    read only=no
    write list = admin1
    valid users = admin1
    public = no
    create mask = 0775
    directory mask = 0775

[user1]
    comment=user1
    path=/home/smb/user1
    read  only=no
    write list = user1
    valid users = user1
    public = no
    create mask = 0775
    directory mask = 0775
  • Start the Samba service

  systemctl start smb
  netstat -lntp|grep smb
  • log in

 

 

Note: During the test, log in to the Samba server with the Windows system. The next time you log in, the user name will remain the same. You can use net use * / del / y to clear the user login information

Guess you like

Origin www.cnblogs.com/psc0218/p/12752699.html