Redhat7 配置samba
安装:
# yuminstall samba samba-common samba-client
启动服务:
#systemctl start smb
#systemctl start nmb
#systemctl enable smb
#systemctl enable nmb
配置文件路径:/etc/samba/smb.conf
samba端口:TCP:139,445 UDP:137,138
装好后默认是user模式(貌似redhat7去掉了share模式)
security= user,ads,domain/server
创建samba账号(须有对应本地账号):
# smbpasswd –a aa
输入密码
修改samba密码命令:
# smbpasswd aa (用户自己改直接敲smbpasswd即可)
删除samba账号:
# smbpasswd –e aa
开放防火墙:
# firewall-cmd –permanent –add-service=smb
# firewall-cmd –permanent –add-service=nmb
# firewall-cmd –reload
此时用账号访问samba直接进的家目录(默认设置)
但登录后发现进不去,须设置下selinux
# setsebool –P samba_enable_home_dirs on (smb.conf里有关于selinux的提示)
如果客户端需要通过cifs方式进行挂载(否则没权限查看里面的数据)
# setsebool -P samba_export_all_ro on
# setsebool -P samba_export_all_rw on
查看账号对应共享:
# smbclient–L //10.0.0.2 -U aa%123456 (aa为账号,123456为密码,中间是%)
允许匿名访问是在security =user下添加map to guest = bad user
客户端cifs挂载(需先安装cifs-utils)
# mount -o username=ming,password=123456 -t cifs //10.0.0.2/home /aa
写入/etc/fstab:
# vi/etc/fstab
//10.0.0.2/home /aa cifs defaults,username=ming,password=123456 0 0
:wq