安装对应的软件包
[root@hds /]# yum install samba samba-client -y
配置四个无法登录的用户
[root@hds /]# useradd -s /sbin/nologin tom
[root@hds /]# useradd -s /sbin/nologin jerry
[root@hds /]# useradd -s /sbin/nologin jack
[root@hds /]# useradd -s /sbin/nologin man
useradd: group man exists - if you want to add this user to that group, use -g.
将man用户移动至man组即可
查看man组ID
[root@hds /]# cat /etc/group | grep man
man:x:15:
[root@hds /]# useradd -g 15 man
创建组并将用户添加至对应的组
[root@hds /]# useradd -g 15 man
[root@hds /]# groupadd administration
[root@hds /]# groupadd sales
[root@hds /]# groupadd manager
[root@hds /]# gpasswd -a tom administration
Adding user tom to group administration
[root@hds /]# gpasswd -a jerry administration
Adding user jerry to group administration
[root@hds /]# gpasswd -a jerry sales
Adding user jerry to group sales
[root@hds /]# gpasswd -a jack sales
Adding user jack to group sales
[root@hds /]# gpasswd -a man manager
Adding user man to group manager
创建共享目录
[root@hds samba]# mkdir /var/administration_share
[root@hds samba]# mkdir /var/sales_share
[root@hds samba]# mkdir /var/public_share
配置主配置文件
[root@hds /]# cd /etc/samba/
给用户配置可以登录smb的密码(密码同用户名)
[root@hds samba]# smbpasswd -a tom
New SMB password:
Retype new SMB password:
Added user tom.
[root@hds samba]# smbpasswd -a jerry
New SMB password:
Retype new SMB password:
Added user jerry.
[root@hds samba]# smbpasswd -a jack
New SMB password:
Retype new SMB password:
Added user jack.
[root@hds samba]# smbpasswd -a man
New SMB password:
Retype new SMB password:
Added user man.
给共享目录最高级权限
[root@hds var]# chmod 777 administration_share/
[root@hds var]# chmod 777 sales_share/
[root@hds var]# chmod 777 public_share/
重启服务并设置为开机自启动
[root@hds var]# systemctl restart smb
[root@hds var]# systemctl enable smb
Created symlink /etc/systemd/system/multi-user.target.wants/smb.service → /usr/lib/systemd/system/smb.service.
测试
[root@hds var]# smbclient //192.168.126.166/administration_share -U tom
所有用户都登录一遍,检测用户的权限。