1、使用的软件叫samba,yum install samba即可
2、修改配置文件如下
setsebool -P samba_domain_controller on
setsebool -P samba_enable_home_dirs on
setsebool -P samba_export_all_rw on
[global]
workgroup = UPOA
server string = Samba Server Version %v
create mask = 0777
directory mask = 0777
# log files split per-machine:
log file = /var/log/samba/log.%m
# maximum size of 50KB per log file, then rotate:
max log size = 50
security = user
# the following login script name is determined by the machine name
# (%m):
# the following login script name is determined by the UNIX user used:
# use an empty path to disable profile support:
# various scripts can be used on a domain controller or a stand-alone
# machine to add or delete corresponding UNIX accounts:
load printers = yes
cups options = raw
# obtain a list of printers automatically on UNIX System V systems:
[homes]
comment = Home Directories
browseable = no
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
[public]
comment = public file
path = /home/xx
valid users = root
writable = yes
browseable = yes
~
注意:"#"和" ; "开头的配置文件都是注释,不同之处在于“ ; ”可要可不要,#是完全可以不要。
3、修改强制访问控制(SELinux 全称 Security Enhanced Linux (安全强化 Linux),是 MAC (Mandatory Access Control,强制访问控制系统)的一个实现,目的在于明确的指明某个进程可以访问哪些资源(文件、网络端口等)。)
setsebool -P samba_enable_home_dirs on
setsebool -P samba_export_all_rw on
完事儿之后再:getsebool -a | grep samba一把
4、重启smb服务service smb restart
5、在windows我的电脑里输入ip即可访问
2017.2.8补充
世界上最蛋疼的事就是对着之前的操作文档来做,结果发现不行。。
补充两条:
6修改SELinux安全策略后,还需要关闭iptables服务或者参考http://blog.chinaunix.net/uid-23069658-id-3142052.html?page=3这个作者的做法,我没弄来,直接停了iptables服务,因为我的系统是centos7,默认又没有按照iptables服务,因此参考了这篇文章http://www.landui.com/help/show-3003.html:
centos从7开始默认用的是firewalld,这个是基于iptables的,虽然有iptables的核心,但是iptables的服务是没安装的。所以你只要停止firewalld服务即可:
sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service
如果你要改用iptables的话,需要安装iptables服务:
sudo yum install iptables-services
sudo systemctl enable iptables && sudo systemctl enable ip6tables
sudo systemctl start iptables && sudo systemctl start ip6tables
7、window连接smb服务时,要求输入用户名密码,蛋疼,怎么输都不对。
原因是我压根还没设置smb的登录密码,虽然用户是root,但是密码却是空,因此怎么登都登不进去,参考这篇文章http://blog.csdn.net/lucky_greenegg/article/details/50481294?locationNum=13
[root@wukong01 louis]# smbpasswd -a root
设置完密码之后就能成功登录和使用smb服务了
2017.5.16
指定端口启动smbd服务
smbd --port=1315 -D
改了端口后,windows不知道怎么访问了....谁有方案【help】
参考链接:
http://bbs.51cto.com/thread-703270-1.html
http://blog.chinaunix.net/uid-23069658-id-3142052.html
http://blog.csdn.net/testcs_dn/article/details/19758163
http://blog.csdn.net/lucky_greenegg/article/details/50481294?locationNum=13
http://www.landui.com/help/show-3003.html: