centos7安装samba,实现共享文件夹,Windows远程访问centos文件

检查samba环境

rpm -qi samba

安装

yum -y install samba samba-client

配置

进入samba配置目录

cd /etc/samba/

备份smb.conf

mv smb.conf  smb.conf.origin

 

新建smb.conf

vim 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 = /共享的文件夹路径

        public = yes

        writeable = yes
        create mask = 0644
        directory mask = 0755

 

[WebDev]

        comment = project development directory

        path = /smb/webdev

        valid users = ted

        write list = ted

        printable = no

        create mask = 0644

        directory mask = 0755

 

创建共享目录授权

chown nobody:nobody /共享的文件夹路径

启动Samba服务,设置开机启动

systemctl start smb

systemctl enable smb

 

 

检查软件

yum provides /usr/sbin/semanage

安装SEliunx

yum install -y policycoreutils-python

设置管理策略

semanage fcontext -a -t samba_share_t /共享的文件夹路径

上下文策略生效

restorecon -Rv /共享的文件夹路径

重启smb

systemctl restart smb

查看smb在SEliunx 策略

getsebool -a | grep samba

SElunux开启写入权限

setsebool -P samba_enable_home_dirs=on

setsebool -P samba_export_all_rw=on

 

最后设置共享文件夹的权限

chmod -R 777 /共享文件夹路径

你可能感兴趣的:(服务器)