我想使用 Samba 共享一个文件夹,并且该文件夹应该受用户名-密码组合的保护(实际上这很常见)。到目前为止,我所做的是:
- 安装 samba(已经安装)
- useradd -m -g 用户 sambauser
- 密码 sambauser
- smbpasswd -a samba用户
我的配置文件:
[global]
workgroup = WORKGROUP
security = share
share modes = yes
[homes]
comment = Home Directories
browsable = no
read only = no
create mode = 0750
[JanGrimm]
path = /media/JanGrimm
public = no
writable = yes
comment = Jan
printable = no
valid users = sambauser
JanGrimm 是媒体中的共享文件夹,所以我的共享文件夹的路径是 /media/JanGrimm
因此,我重新启动了 samba 服务,然后尝试在 Windows(10)下映射网络驱动器:
提示输入凭证:
现在连接:
过了一段时间,它再次提示我:
显然,无论我输入什么,它都不起作用。为了尝试,我禁用了服务器的防火墙。这有什么问题?我就是无法绕过。
答案1
我在 Windows10 上,我们正在使用以下有效的 samba 配置
[global]
workgroup = WORKGROUP
server string = %h server (Samba, Ubuntu)
netbios name = FileServer
wins support = yes
dns proxy = no
name resolve order = lmhots host wins bcast
interfaces = 192.168.0.1/24 eth0
bind interfaces only = yes
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
server role = standalone server
passdb backend = tdbsam
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
map to guest = bad user
usershare allow guests = yes
[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = no
read only = yes
create mask = 0700
# Windows clients look for this share name as a source of downloadable
# printer drivers
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = yes
guest ok = no
[MY_SHARE]
writeable = yes
path = <your/File/Path>
comment = Fileserver
guest account = <validUser>
wide links = no
security = user
也许它能帮助你找到解决方案。请注意,特别是在全局部分,你的配置对我来说似乎很短
答案2
这在 Windows 10 中非常奇怪:如果您在 Windows 机器上使用与 Samba 服务器上相同的用户 ID/密码,实际上,您不需要提供密码。
例如,如果您在 Windows 中被称为“userw”,密码为“xyz”,并且在 Samba 中定义了完全相同的用户和密码,当 Windows 10 上提示您输入用户 ID/密码时,只需输入用户 ID无需输入任何密码. 这就行了。
请注意,如果您输入的密码即使正确,连接也将失败。
另外,根据您的配置文件,确保您连接的域是“WORKGROUP”。