Linux简易配置之samba

安装相关软件添加到开机启动

yum -y install samba

chkconfig smb on

chkconfig nmb on


关闭selinux防火墙,默认为1,否则不能读写

[root@localhost ~]# getenforce

Enforcing

[root@localhost ~]# setenforce 0

[root@localhost ~]# getenforce

Permissive


对iptables做如下操作并保存

iptables -I INPUT 4 -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT

iptables -I INPUT 5 -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT

iptables -I INPUT 6 -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT

service iptables save


备份配置文件

cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

rm /etc/samba/smb.conf

touch /etc/samba/smb.conf

vi /etc/samba/smb.conf


配置一个公开的访问目录,在新创建的smb.conf文件中加入以下配置

[global]

workgroup = WORKGROUP

security = share

map to guest = bad user

[share]

path = /home/share

browsable =yes

writable = yes

guest ok = yes

read only = no


设置文件夹权限,检测配置文件,重启服务

chmod -R 0777 /home/share

testparm

service smb restart

service nmb restart


-----------------------------以上是CentOS6.8,以下是RHEL5-----------------------------


iptables -A INPUT -p tcp --dport 139 -j ACCEPT

samba配置路径 /etc/samba/smb.conf

服务器重启动 service smb restart         测试配置文件 testparm


workgroup = workgroup     #设置加入工作组

server string = CWen's Server string     #设置服务器注释信息

security = share  #share用户不需要帐密登陆samba服务器;user使用samba所在服务器检查帐密

hosts deny = 192.168.1.        #设置拒绝访问


security = share #允许所有人读写

[cwen]           

comment = cwen's comment   #目录注释信息

path = /home/cwen#共享目录路径chmod -R 777 /home/cwen 设置目录权限

public = yes#所有可读   同 guest ok = yes  

writable = yes#可写



smbpasswd -a test #创建用户test的samba密码

security = user


[public]#允许组test 组tech 用户market 读写

path = /home/public#共享目录路径chmod -R 777 /home/cwen 设置目录权限

valid users=@test @tech market#允许组test 组tech 用户market 访问     相反invalid users

writable = yes#可写


[test]#允许 组test 读写  其他成员只能浏览

path = /home/test#共享目录路径chmod -R 777 /home/cwen 设置目录权限

public = yes#所有可读

write list = @test# 组test 可写


vim /etc/samba/smbusers - t4 = t1 t2#映射 用户t1、用户t2  到 用户t4(使用t4的权限访问)

[test]#允许 组test 读写  其他成员只能浏览

path = /home/test#共享目录路径chmod -R 777 /home/cwen 设置目录权限

public = yes#所有可读

write list = @t4# 组t4 用户t1 用户t2 可写


安装smbclient:rpm -ivh samba-client-3.0.33-3.37.el5.x86_64.rpm --force --nodeps

smbclient //192.168.1.20/abc -U cwen#使用用户cwen访问192.168.1.20的abc文件夹

注:windows清除共享密码连接等    net use * /delete


评论

  • *
  • *