1 安装samba
在线安装命令:
[root@localhost ~]# yum install samba
安装完成后查询得到:
[root@localhost ~]# rpm -qa | grep samba
samba-common-tools-4.2.10-7.el7_2.x86_64
samba-common-libs-4.2.10-7.el7_2.x86_64
samba-libs-4.2.10-7.el7_2.x86_64
samba-common-4.2.10-7.el7_2.noarch
samba-client-libs-4.2.10-7.el7_2.x86_64
samba-4.2.10-7.el7_2.x86_64
#2 配置samba
root用户安全验证登录模版
修改/etc/samba/smb.conf
文件
[root@localhost ~]# vi /etc/samba/smb.conf
[global]
security = user #只能用user
map to guest = bad user
共享目录以及权限,可以添加到最后
[data]
path=/root/data
browsable =yes
writable = yes
guest ok = yes
valid user = root
read only = no
更改共享文件夹读写权限:
[root@localhost ~]# chmod –R 777 /root/data
重启进程,打开进程自启动
[root@localhost ~]# systemctl enable smb.service
[root@localhost ~]# systemctl enable nmb.service
[root@localhost ~]# systemctl restart smb.service
[root@localhost ~]# systemctl restart nmb.service
3 关闭selinux
[root@localhost ~]# vi /etc/selinux/config
将SELINUX=enforcing
改为SELINUX=disabled
, 重启机器即可
直接执行命令:
[root@localhost ~]# setenforce 0
可以临时关闭,重启之后不在。
4 关闭防火墙
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@localhost ~]# firewall-cmd --state
not running
5 samba用户管理
[root@localhost ~]# useradd root -d /root/data -s /bin/false #添加samba用户
[root@localhost ~]# smbpasswd -a root#设置samba的登录密码
6 开启启动项设置
开机默认关闭防火墙
[root@localhost ~]# chkconfig --level 345 firewalld off
开机默认启动samba
[root@localhost ~]# chkconfig --level 345 smb on