#安装samba*
[root@localhost /]# yum -y install samba*
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
软件包 samba-client-libs-4.4.4-9.el7.x86_64 已安装并且是最新版本
软件包 samba-common-4.4.4-9.el7.noarch 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 samba.x86_64.0.4.4.4-9.el7 将被 安装
---> 软件包 samba-client.x86_64.0.4.4.4-9.el7 将被 安装
---> 软件包 samba-common-libs.x86_64.0.4.4.4-9.el7 将被 安装
---> 软件包 samba-common-tools.x86_64.0.4.4.4-9.el7 将被 安装
---> 软件包 samba-krb5-printing.x86_64.0.4.4.4-9.el7 将被 安装
---> 软件包 samba-libs.x86_64.0.4.4.4-9.el7 将被 安装
-------------------------------------------------。。。。。。
#创建samba用户 需要系统已有用户
vim /etc/passwd #查看用户
#创建系统用户
[root@localhost /]# useradd tom
[root@localhost /]# passwd tom
#创建samba用户
[root@localhost /]# smbpasswd -a nike
New SMB password:
Retype new SMB password:
Added user nike.
#查看samba用户列表
[root@localhost /]# pdbedit -L
nike:1000:redhat
#创建共享文件夹
[root@localhost ~]# cd /opt
[root@localhost opt]# mkdir samba_yin
[root@localhost opt]# cd samba_yin/
[root@localhost samba_yin]# touch xx
[root@localhost samba_yin]# ls
xx
#给文件夹权限
[root@localhost opt]# chmod -R 777 samba_yin/
#配置文件
vim /etc/samba/smb.conf
#示例文件
[root@localhost /]# vim /etc/samba/smb.conf.example
#看行数
:set nu
#写入
[global]
workgroup = STAFF #工作组
[samba]
path = /opt/samba_yin #共享路径
public = yes #允许访问
browseable = yes #可被读取
hosts allow = 192.168.10. #被允许通过网段 (可不写)
interfaces = 192.168.10.10/24 #开放在什么网卡上(可不写)
writable =yes #写权限全部开放
write list = nike,tom #某些用户写权限开放(不与writable 一起用)
valid users = nike,tom #允许某些用户访问(更为精确)
#查看端口
netstat -pant | grep 139
netstat -pant | grep 445
#重启服务
systemctl restart smb
systemctl restart nmb
#防火墙
#放行samba
[root@localhost ~]# firewall-cmd --permanent --add-service=samba
success
#重新加载
[root@localhost ~]# firewall-cmd --reload
success
#seliunx
#查看状态
[root@localhost /]# getenforce
Enforcing
#
setsebool -P samba_domain_controller on #域名访问
setsebool -P samba_enable_home_dirs on #属主目录
chcon -t samba_share_t /opt/samba_yin/ #上下文修改
setsebool -P samba_export_all_rw on #可读可写文件
#win进入文件夹
\\192.168.10.10
#客户端访问
#先安装samba-client
yum -y -install samba-client
smbclient -U nike //192.168.10.10/samba #与配置文件[samba]一致
浙公网安备 33010602011771号