1、关闭SELinux和防火墙
1.1临时关闭(不用重启机器)
[root@TEST-2 ~]# setenforce 0 #设置selinux成为permissive模式 (关闭selinux)
[root@TEST-2 ~]# setenforce 1 #设置selinux成为enforcing模式 (开启selinux)
1.2修改配置文件需要重启机器
[root@TEST-2 ~]# vi /etc/selinux/config
将SELINUX=enforcing 改为SELINUX=disabled(需重启机器)
[root@docker01 ~]# setenforce 0
1.3可自己做策略开发相应端口,这里我直接关闭
2、按照samba服务
2.1直接yum安装
[root@TEST-2 ~]# yum install samba samba-client
2.2启动并查看samba
[root@TEST-2 ~]# systemctl start smb nmb #注:NMB对客户端提供NetBIOS服务
[root@TEST-2 ~]# systemctl status smb nmb
3、配置samba服务
[root@TEST-2 ~]# cp /etc/samba/smb.conf /etc/samba/smb.confbak
[root@TEST-2 ~]# vi /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
server string = Ted Samba Server %v
netbios name = TedSamba
security = user
map to guest = Bad User
passdb backend = tdbsam
[FileShare]
comment = share some files
path = /smb/fileshare
public = yes
writeable = yes
create mask = 0644
directory mask = 0755
[WebDev]
comment = project development directory
path = /smb/webdev
valid users = ted
force group = co3
write list = ted
printable = no
create mask = 0644
directory mask = 0755
workgroup 项应与 Windows 主机保持一致,这里是WORKGROUP
security、map to guest项设置为允许匿名用户访问
再下面有两个section,实际为两个目录,section名就是目录名(映射到Windows上可以看见)。
第一个目录名是FileShare,匿名、公开、可写
第二个目录吗是WebDev,限定ted用户访问
默认文件属性644/755(不然的话,Windows上在这个目录下新建的文件会有“可执行”属性)
4、创建用户
[root@TEST-2 samba]# groupadd co3
[root@TEST-2 samba]# useradd ted -g co3 -s /sbin/nologin
[root@TEST-2 samba]# smbpasswd -a ted #设置密码为123
New SMB password:
Retype new SMB password:
Added user ted.
5、创建共享目录
[root@TEST-2 samba]# mkdir -p /smb/{fileshare,webdev}
[root@TEST-2 samba]# chown nobody:nobody /smb/fileshare/
[root@TEST-2 samba]# chown ted:co3 /smb/webdev/
#注意设置属性,不然访问不了
6、启动samba服务,设置开机启动
[root@TEST-2 samba]# systemctl restart smb nmb
[root@TEST-2 samba]# systemctl enable smb nmb
7、开发端口
[root@TEST-2 samba]# firewall-cmd –permanent –add-port=139/tcp
success
[root@TEST-2 samba]# firewall-cmd –permanent –add-port=445/tcp
success
[root@centos9 packages]# firewall-cmd –reload
[root@TEST-2 samba]# systemctl restart firewalld
8、本机测试
[root@TEST-2 samba]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section “[FileShare]”
Processing section “[WebDev]”
Loaded services file OK.
Server role: ROLE_STANDALONE
……………………….
[WebDev]
comment = project development directory
path = /smb/webdev
create mask = 0644
valid users = ted
write list = ted
9、windows登陆
10、网络映射
留言