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的话,可以试试以下操作:程序代码:
/etc/init.d/smb start 7 开机启动
chkconfig smb on
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
相关文章推荐
- centos6.4 32位 详细安装Nginx
- CentOS6.4安装Samba(匿名)共享服务器
- centos 6.4安装samba方法
- linux(centos 7)下安装elasticsearch - head插件(端口占用,防火墙关闭)
- centos6.4关闭防火墙步骤
- centos6.4 32位 安装ruby on rails
- linux,Centos 6.3 yum安装Nginx+php+Mysql,配置防火墙,开启,关闭端口命令
- CentOS 7 关闭防火墙(firewall)并安装iptables防火墙
- centos6.4 samba 安装
- centos7 关闭firewall防火墙指令以及更换安装iptables并配置
- CentOS 6.4安装 Samba 4 并绑定 Active Directory Domain Controller 域控
- hadoop学习;安装jdk,workstation虚拟机v2v迁移;虚拟机之间和跨物理机之间ping网络通信;virtualbox的centos中关闭防火墙和检查服务启动
- centOS 6.4关闭防火墙步骤
- centos6.4 32位系统安装mongodb及php扩展
- CentOS 6.4 安装 samba (未完)
- 在32位Centos6.4上安装GraphicsMagick
- centOS6.4 部分常用软件 安装配置 (LAMP,PYTHON,SAMBA等不定期更新)
- U盘安装CentOS6.4 32位bin版的心得体会
- centos7 关闭firewall安装iptables并配置防火墙
- hadoop学习;安装jdk,workstation虚拟机v2v迁移;虚拟机之间和跨物理机之间ping网络通信;virtualbox的centos中关闭防火墙和检查服务启动