您的位置:首页 > 运维架构 > Linux

centos 6.4_32位不关闭防火墙的samba安装

2015-01-21 12:19 323 查看
1 安装
yum -y install samba 2 修改配置文件
vi /etc/samba/smb.conf
1)全局配置
[global]
workgroup = WORKGROUP #要访问的电脑的工作组名,windows一般默认都为这个
hosts allow = 127. 192.168.128. #去掉前面的分号,并修改能访问的网段(注意,由于本地与虚拟机是通过nat联网的,所以这里的网段是虚拟机的网段)
security = share #访问的方式,share不需要密码,user需要用户名和密码2)文档最后添加共享的目录,并且允许写操作
[public]
comment = public Stuff
path = /home/samba
public = yes
writable = yes 3 创建共享文件
mkdir /home/samba 4 修改共享文件权限
chmod 777 /home/samba添加samba用户使用smbpasswd添加samba用户,用户必须是linux系统中已有的用户,密码则不必和系统用户相同。如果没有,添加用户先。#useradd smb# smbpasswd smb (在windows下访问linux需要的密码)
New SMB password:
Retype new SMB password:
Failed to find entry for user root.
Failed to modify password entry for user root出现上面这个错的原因是因为需要为root用户创建一个用户,使用smbpasswd –a root就可以解决了。说明是没有该用户,请使用 -a 参数OPTIONS
-a
This option specifies that the username following should be added to the local smbpasswd file, with the new
password typed (type <Enter> for the old password). This option is ignored if the username following
already exists in the smbpasswd file and it is treated like a regular change password command. Note that
the default passdb backends require the user to already exist in the system password file (usually
/etc/passwd), else the request to add the user will fail. This option is only available when running smbpasswd as root.解决方法:加参数‘-a’:# smbpasswd -a 用户即可,如下: # smbpasswd -a smb
New SMB password:
Retype new SMB password:
Added user root.
5)修改/etc/samba/smb.conf,在其中添加: [public] valid users = smb(用户名)
5 防火墙开放端口(或者是直接关闭 /etc/init.d/iptables stop)
1)开放端口
iptables -I INPUT -p udp --dport 137 -j ACCEPT
iptables -I INPUT -p udp --dport 138 -j ACCEPT
iptables -I INPUT -p tcp --dport 139 -j ACCEPT
iptables -I INPUT -p tcp --dport 445 -j ACCEPT
2)保存配置
/etc/init.d/iptables save
3)重启防火墙
/etc/init.d/iptables restartselinux设置 默认的,SELinux禁止网络上对Samba服务器上的共享目录进行写操作,即使你在smb.conf中允许了这项操作。 假设你已经配置了共享目录/share并允许用户进行读写,而你又不想关闭SELinux的话,可以试试以下操作:程序代码:
#/usr/sbin/setsebool -P allow_smbd_anon_write=1
#chcon -t public_content_rw_t /home/samba
其中第一条语句设置SELinux放行标记了public_content_rw_t的内容,第二条语句把欲共享的/share目录标记为public_content_rw_t。 附SELinux资料:selinux简介SElinux 在linux内核级别上提供了一个灵活的强制访问控制系统(MAC),这个强制访问控制系统是建立在自由访问控制系统(DAC)之上的。6 启动samba服务
/etc/init.d/smb start 7 开机启动
chkconfig smb on
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  samba centos