1.配置一个简单指定用户共享:
服务器端:
1.关闭防火墙(4步)
[root@lihuaixin ~]# systemctl stop firewalld
[root@lihuaixin ~]# systemctl disable firewalld
[root@lihuaixin ~]# vim /etc/selinux/config (改为SELINUX=enforcing
)
[root@lihuaixin ~]# setenforce 0
2、安装samba服务(yum install -y samba*)
[root@lihuaixin ~]# yum -y install samba*
启动服务
[root@lihuaixin ~]# systemctl start smb nmb
3、创建samba系统用户并为系统用户设置密码
[root@lihuaixin ~]# useradd tom
[root@lihuaixin ~]# id tom
uid=1017(tom) gid=1017(tom) 组=1017(tom)
[root@lihuaixin ~]# smbpasswd -a tom
New SMB password:
Retype new SMB password:
Added user tom.
[root@lihuaixin ~]#
4、在/etc/samba/smb.conf配置文件下加入指定共享的用户和目录
[XXX]
path=XXX (共享目录)
Valid users = XXX (允许那个用户能够访问
[lihuaixin]
path = /huannai
valid users = tom
5、testparm测试配置是否有语法错误
[root@lihuaixin ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[lihuaixin]"
Unknown parameter encountered: "valid user"
Ignoring unknown parameter "valid user"
Loaded services file OK.
Server role: ROLE_STANDALONE
6、重启samba服务
[root@lihuaixin ~]# systemctl restart smb nmb
客户端:
1、关闭防火墙
[root@lihuaixin ~]# systemctl stop firewalld
[root@lihuaixin ~]# systemctl disable firewalld
[root@lihuaixin ~]# vim /etc/selinux/config (改为SELINUX=enforcing
)
[root@lihuaixin ~]# setenforce 0
2、安装samba客户端(yum install -y samba-client)
[root@qiaobenhuannai ~]# yum -y install samba-client
3、查看服务器端的共享资源smbclient -L host -U user(系统用户)
[root@qiaobenhuannai ~]# smbclient -L 192.168.199.128 -U tom
Enter SAMBA\tom's password:
Domain=[LIHUAIXIN] OS=[Windows 6.1] Server=[Samba 4.6.2]
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
lihuaixin Disk
IPC$ IPC IPC Service (Samba 4.6.2)
tom Disk Home Directories
Domain=[LIHUAIXIN] OS=[Windows 6.1] Server=[Samba 4.6.2]
Server Co