搭建用户认证共享服务器
1.准备工作
环境
ip | 主机 | 环境 |
---|---|---|
172.16.30.30 | system2 | redhat7图形界面 |
172.16.30.130 | system1 | redhat7图形界面 |
2.服务端
关防火墙和selinux。安装samba服务
[root@system2 Desktop]# systemctl stop firewalld.service
[root@system2 Desktop]# setenforce 0
[root@system2 Desktop]# yum -y install samba-*
[root@system2 Desktop]# useradd -M jianghu
[root@system2 Desktop]# smbpasswd -a jianghu
New SMB password:
Retype new SMB password:
Added user jianghu.
[root@system2 Desktop]# echo 'jianghu = share' > /etc/samba/smbusers
[root@system2 Desktop]# vim /etc/samba/smb.conf
[root@system2 Desktop]# mkdir -p /hupu/jianghu
[root@system2 Desktop]# chown -R jianghu.jianghu /hupu/jianghu/
[root@system2 Desktop]# ll /hupu/
total 0
drwxr-xr-x. 2 jianghu jianghu 6 Jan 15 09:43 jianghu
[root@system2 Desktop]# cat >> /etc/samba/smb.conf <<EOF
> [jianghu]
> comment = jianghu
> path = /hupu/jianghu
> browseable = yes
> guest ok = yes
> writable = yes
> write list = share
> public = yes
> EOF
[root@system2 Desktop]# tail -8 /etc/sa
samba/ sane.d/ sasl2/
[root@system2 Desktop]# tail -8 /etc/samba/smb.conf
[jianghu]
comment = jianghu
path = /hupu/jianghu
browseable = yes
guest ok = yes
writable = yes
write list = share
public = yes
[root@system2 Desktop]# systemctl start smb
[root@system2 Desktop]# systemctl restart smb
[root@system2 Desktop]# systemctl reload smb
[root@system2 Desktop]# systemctl enable smb
ln -s '/usr/lib/systemd/system/smb.service' '/etc/systemd/system/multi-user.target.wants/smb.service'
3.客户端验证
[root@system1 Desktop]# smbclient -L 172.16.30.30 -U share
Enter share's password:
Domain=[SAM