1、在共享服务端安装samba:# yum install samba samba-client.x86_64 samba-common -y
2、在共享服务端需要防火墙开通139、445端口:
# firewall-cmd --zone=public --add-port=139/tcp --permanent
# firewall-cmd --zone=public --add-port=445/tcp --permanent
# firewall-cmd --zone=public --add-port=139/udp --permanent
# firewall-cmd --zone=public --add-port=445/udp --permanent
# firewall-cmd --reload
3、在共享服务端启动samba:# systemctl start smb
在共享服务端停止samba:# systemctl stop firewalld.service
在共享服务端重启samba:# systemctl restart smb.service
4、在共享服务端建立用户
重置密码:# smbpasswd -a root
查看samba用户:# pdbedit -L
smbuser为默认本地用户
添加新用户:# useradd new
为新用户添加新密码:# smbpasswd -a new
删除samba用户:# pdbedit -x lee
使用户使用samba功能:# setsebool -P samba_enable_home_dirs on
5、在共享客户端:yum install samba-client -y
6、在共享客户端测试:# smbclient -L //192.168.x.xx (该IP为共享服务端ip)
7、在共享服务端配置samba:# vim /etc/samba/smb.conf
[global]
workgroup = MYGROUP # 工作群组 server string = Samba Server Version %v # 设定samba server的注解 log file = /var/log/samba/log.%m # 日志samba存放位置 max log size = 50 # 日志的大小 security = user # 设定samba的安全级别 passdb backend = tdbsam load printers = yes cups options = raw [homes] comment = Home Directories browseable = no writable = yes[pack]
comment = file_pack # 注释说明 path = /home/pack # 资源路径 valid users =new # 此名单内才能访问 directory mask = 775 # 给的权限 writable = yes # 无视read only browseable = yes # 浏览资源中显示共享目录,若为否则必须指定共享路径才能存取[photo]
comment = file_photo path = /home/gcisp/cloud/photo valid users = root directory mask = 775 writable = yes browseable = yes详细配置请见:https://www.cnblogs.com/fatt/p/5856892.html
8、在共享客户端测试:# smbclient -L // 192.168.x.xx -U new (输入new用户的密码)
9、在共享客户端手动挂载:# mount //192.168.xx.x/pack /home/pack -o username=new,password=123
10、在共享客户端永久挂载:# vim /etc/fstab 添加下列一行:
//192.168.xx.x/pack /home/pack cifs defaults,username=new,password=123 0 0
注解://192.168.xx.x/pack(pack为共享服务端的包名) /home/pack(挂载点) cifs defaults,username=new,password=123 0 0
11、拓展挂载命令:http://www.runoob.com/linux/linux-comm-mount.html