我正在尝试为我的整个网络进行公共共享(匿名和用户),没有任何限制。当我尝试从任何计算机(win10 和 debian 10)访问公共共享时,我总是被拒绝访问,我已经检查了所有用户是否已添加到服务器(通过 pdbedit -w -L 检查)。服务器上的端口已打开,简单的 ncat 显示我能够连接。
Windows 登录尝试:
The password is invalid for \\IP.IP.IP.IP\Public.
Enter the user name for 'IP.IP.IP.IP: user1
Enter the password for IP.IP.IP.IP:
System error 5 has occurred.
Access is denied.
Linux 登录尝试:
smbclient //IP.IP.IP.IP/Public /mnt/Public
Unable to initialize messaging context
Anonymous login successful
tree connect failed: NT_STATUS_ACCESS_DENIED
smb.conf:
#======================= Global Settings =======================
[global]
workgroup = WORKGROUP
min protocol = SMB2
max protocol = SMB2
security = user
null passwords = yes
map to guest = Bad User
guest ok = Yes
#======================= Share Definitions =======================
[Public]
comment = Public Share
path = /share0
writable = yes
available = yes
browsable = yes
guest ok = yes
当我跑步时ls -ld /share0
我得到这个
drwxrwxrwx 2 root root 4096 Sep 12 15:22 share0
答案1
好吧,这是行不通的。正如你所注意到的。毕竟你的份额是拥有的由 root 操作并且您没有指定来宾用户。
正确的方法是提供访客用户guest account = ...
(johndoe
如下)。
这是一个工作配置:
$ testparm -s
# Global parameters
[global]
dns proxy = No
guest account = johndoe
log file = /var/log/samba/log.%m
map to guest = Bad Password
max log size = 1000
panic action = /usr/share/samba/panic-action %d
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
passwd program = /usr/bin/passwd %u
security = USER
server role = standalone server
server string = %h server (Samba, Ubuntu)
workgroup = NULL
idmap config * : backend = tdb
[share]
force create mode = 0660
force directory mode = 0770
guest ok = Yes
guest only = Yes
path = /share
read only = No
您可能要考虑的第二个设置是guest only = ...
(取决于您的真的想要实现)。我发现忽略force directory mode
andforce create mode
给我带来了问题。哦,别忘了chown -R johndoe: ...
你的分享(替换用户名
答案2
感谢 0xC0000022L,我获得了适用于所有用户的共享
随着配置:
[global]
guest account = guest
log file = /var/log/samba/log.%m
logging = file
map to guest = Bad Password
max log size = 1000
obey pam restrictions = Yes
pam password change = Yes
panic action = /usr/share/samba/panic-action %d
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
passwd program = /usr/bin/passwd %u
security = USER
server max protocol = SMB2
server min protocol = SMB2
server role = standalone server
unix password sync = Yes
idmap config * : backend = tdb
guest ok = Yes
[Public]
comment = Public Share
create mask = 0700
directory mask = 0700
path = /share0
并valid users = %S
在/etc/samba/smb.conf中注释掉