`

Samba快捷匿名访问设置

 
阅读更多

主要步骤有3:

1,开通需要开通的防火墙端口,tcp139,tcp455,udp137,udp138

vi /etc/sysconfig/iptables
增加(或确认存在)一下记录
#NetBIOS
-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT 
-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT 
#Samba
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT

 备注,138,139 是高危端口,根据情况添加,以上中445是必须的。

 

2,配置samba:

[root@lan ~]#yum -y install samba
[root@lan ~]#mkdir /home/share
[root@lan ~]#chmod 777 /home/share

[root@lan ~]#vi /etc/samba/smb.conf
# near line 58: add

unix charset = UTF-8

dos charset =GBK
# line 75: change (Windows' default)

workgroup =WORKGROUP
# line 81: uncomment and change IP address you allow

hosts allow = 127.10.0.0.
# line 102: change (no auth)

#非必须

security =share
# add at the bottom

#如果必须用指定用户登录,须保持原有的 security = user

[Share]
# any name you like, 但是最好和smb用户名字保持一致,否则会出来两个共享文件夹。

   path = /home/share # shared directory
   writable = yes  # writable
   guest ok = yes # guest OK
   guest only = yes # guest only
   create mode = 0777 # fully accessed
   directory mode = 0777 # fully accessed
   share modes = yes # warn if some people access to a file

 

[root@lan ~]# /etc/rc.d/init.d/smb start
Starting SMB services:[  OK  ]
[root@lan ~]#/etc/rc.d/init.d/nmb start
Starting NMB services:[  OK  ]
[root@lan ~]#chkconfig smb on
[root@lan ~]#chkconfig nmb on

 

3, 如果是W7,W2008,还有一个地方需要单独修改:"从Vista开始,微软默认只采用NTLM v2协议的认证回应消息了,而目前的NAS系统和Samba还只支持LM或者NTLM",所以需要按照网上介绍的办法,见附图

 

 

4,如果就是要加用户登录模式来访问和读写共享文件夹,须要先添加SMB用户(SMB用户必须是操作系统的用户,否则会报加不上用户的错误):

比如,先加用户组和用户:
groupadd smbuser1 -g 6000
useradd smbuser1 -u 6000 -g 6000 -s /sbin/nologin -d /dev/null
/usr/bin/smbpasswd -a smbuser1
然后,配置文件修改成如下(重点是 valid users= smbuser1
 [SMBShare]
path = /share/file/folder
writable = yes
public = yes
create mask = 0777
directory mask = 0777
available = yes
valid users= smbuser1
browseable = yes
 
即可,重启服务后,再访问就需要提供用户名密码才能访问共享文件夹。
 
常见问题:总是提示 workgroup不对,其实是有两个选项没有打开:(
即:
  1. 访问Samba服务器共享文件夹时无法写入问题的解决办法
# 查看权限
[root@localhost ~]# getsebool -a|grep samba
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> off
samba_export_all_rw --> off
samba_load_libgfapi --> off
samba_portmapper --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
tmpreaper_use_samba --> off
use_samba_home_dirs --> off
virt_use_samba --> off
# 设置SELinux服务与策略
[root@localhost ~]# setsebool -P samba_enable_home_dirs=on
[root@localhost ~]# setsebool -P samba_export_all_rw=on
 

参考链接:

Linux操作系统--Samba(十一) - 简书 (jianshu.com)

http://396175583.blog.51cto.com/4074252/736431

http://www.server-world.info/en/note?os=CentOS_6&p=samba

http://wenku.baidu.com/view/1d2557c789eb172ded63b715.html

  • 描述: hjnn
  • 大小: 9.2 KB
  • 大小: 150.5 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics