我最近设置了一个 SAMBA 文件共享。经过一系列步骤后,我终于能够让我的大多数计算机看到这个服务器。主要要求是:1) 它必须受密码保护,2) 有多个用户,3) 每个用户可以拥有一个文件,但所有用户都可以写入彼此的文件。
我的办公室有 5 台 Mac、1 台 Linux 服务器(Ubuntu 13.04)、1 台 Windows 服务器(Windows 2008 R2)和 3 台 Windows XP Pro 台式机。除 Mac 外,所有计算机都可以正常访问共享。
奇怪的是,一台 Mac 可以查看共享并登录。输入用户名和密码后,所有其他 Mac 都无法登录。
以下是我的 smb.conf 文件的内容:
[global]
workgroup = workgroup
server string = %h server (Samba, Ubuntu)
dns proxy = no
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
security = user
encrypt passwords = yes
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
username map = /etc/samba/smbusers
guest ok = no
guest account = nobody
comment = Home Directories
browseable = no
read only = no
create mask = 0775
directory mask = 0775
[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
; guest ok = no
; read only = yes
create mask = 0700
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
[interactive]
path = /home/shok07a/interactive
writeable = yes
browseable = yes
comment = interactive
create mask = 0777
directory mask = 2777
force directory mode = 2777
guest ok = no
force group = sambashare
日志:
启动日志.nmbd:
[2013/08/26 08:51:27.730313, 0] nmbd/nmbd_nameregister.c:492(register_name)
register_name: NetBIOS name SHOK07A-INTERACTIVE-SERVER is too long. Truncating to SHOK07A-INTERAC
[2013/08/26 08:51:27.730464, 0] nmbd/nmbd_nameregister.c:492(register_name)
register_name: NetBIOS name SHOK07A-INTERACTIVE-SERVER is too long. Truncating to SHOK07A-INTERAC
[2013/08/26 08:51:27.730526, 0] nmbd/nmbd_nameregister.c:492(register_name)
register_name: NetBIOS name SHOK07A-INTERACTIVE-SERVER is too long. Truncating to SHOK07A-INTERAC
[2013/08/26 08:53:02.002178, 0] nmbd/nmbd_become_lmb.c:397(become_local_master_stage2)
*****
Samba name server SHOK07A-INTERACTIVE-SERVER is now a local master browser for workgroup WORKGROUP on subnet 10.42.0.1
*****
[2013/08/26 16:45:47.916574, 0] libsmb/nmblib.c:856(send_udp)
Packet send failed to 10.42.0.255(138) ERRNO=Invalid argument
[2013/08/26 16:45:47.916689, 0] libsmb/nmblib.c:856(send_udp)
Packet send failed to 10.42.0.255(138) ERRNO=Invalid argument
[2013/08/26 16:58:56.608481, 0] nmbd/nmbd_incomingdgrams.c:311(process_local_master_announce)
process_local_master_announce: Server SHOK09A-PC at IP 10.42.0.92 is announcing itself as a local master browser for workgroup WORKGROUP and we think we are master. Forcing election.
[2013/08/26 16:58:56.608685, 0] nmbd/nmbd_become_lmb.c:150(unbecome_local_master_success)
*****
Samba name server SHOK07A-INTERACTIVE-SERVER has stopped being a local master browser for workgroup WORKGROUP on subnet 192.168.1.35
*****
[2013/08/26 16:58:56.609163, 0] nmbd/nmbd_nameregister.c:492(register_name)
register_name: NetBIOS name SHOK07A-INTERACTIVE-SERVER is too long. Truncating to SHOK07A-INTERAC
[2013/08/26 16:58:56.609241, 0] nmbd/nmbd_nameregister.c:492(register_name)
register_name: NetBIOS name SHOK07A-INTERACTIVE-SERVER is too long. Truncating to SHOK07A-INTERAC
[2013/08/26 16:58:56.609334, 0] nmbd/nmbd_nameregister.c:492(register_name)
register_name: NetBIOS name SHOK07A-INTERACTIVE-SERVER is too long. Truncating to SHOK07A-INTERAC
[2013/08/26 16:59:13.629340, 0] nmbd/nmbd_become_lmb.c:397(become_local_master_stage2)
*****
Samba name server SHOK07A-INTERACTIVE-SERVER is now a local master browser for workgroup WORKGROUP on subnet 192.168.1.35
*****
结束日志.nmbd
其他日志均未显示任何内容。它们都是空的。我还是保存了它们,清除了日志,并尝试再次连接。我的日志中再次没有任何内容显示。
我从 Mac ping 了机器,所有 ping 都顺利通过。系统提示我输入用户名和密码。
因此看起来机器可以互相“看到”,但是认证失败了。
编辑(更多日志):
[2013/08/27 09:28:29.864230, 2] smbd/reply.c:553(reply_special)
netbios connect: name1=192.168.1.35 0x20 name2=STATION-4 0x0
[2013/08/27 09:28:29.864427, 2] smbd/reply.c:573(reply_special)
netbios connect: local=192.168.1.35 remote=station-4, name type = 0
[2013/08/27 09:34:29.843796, 2] smbd/reply.c:553(reply_special)
netbios connect: name1=192.168.1.35 0x20 name2=STATION-4 0x0
[2013/08/27 09:34:29.844328, 2] smbd/reply.c:573(reply_special)
netbios connect: local=192.168.1.35 remote=station-4, name type = 0
[2013/08/27 09:40:29.850174, 2] smbd/reply.c:553(reply_special)
netbios connect: name1=192.168.1.35 0x20 name2=STATION-4 0x0
[2013/08/27 09:40:29.850389, 2] smbd/reply.c:573(reply_special)
netbios connect: local=192.168.1.35 remote=station-4, name type = 0
Station 4 是无法连接的 Mac 之一。
开始 log.smbd
[2013/08/27 09:25:40, 0] smbd/server.c:1026(main)
smbd version 3.6.9 started.
Copyright Andrew Tridgell and the Samba Team 1992-2011
[2013/08/27 09:25:40, 2] lib/tallocmsg.c:124(register_msg_pool_usage)
Registered MSG_REQ_POOL_USAGE
[2013/08/27 09:25:40, 2] lib/dmallocmsg.c:78(register_dmalloc_msgs)
Registered MSG_REQ_DMALLOC_MARK and LOG_CHANGED
[2013/08/27 09:25:40.140866, 2] param/loadparm.c:4985(max_open_files)
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
[2013/08/27 09:25:40.141089, 2] param/loadparm.c:8327(do_section)
Processing section "[printers]"
[2013/08/27 09:25:40.141181, 2] param/loadparm.c:8327(do_section)
Processing section "[print$]"
[2013/08/27 09:25:40.141246, 2] param/loadparm.c:8327(do_section)
Processing section "[interactive]"
[2013/08/27 09:25:40.141494, 2] lib/interface.c:341(add_interface)
added interface wlan0 ip=fe80::6a94:23ff:feb3:3a9b%wlan0 bcast=fe80::ffff:ffff:ffff:ffff%wlan0 netmask=ffff:ffff:ffff:ffff::
[2013/08/27 09:25:40.141605, 2] lib/interface.c:341(add_interface)
added interface eth0 ip=fe80::7a45:c4ff:fe06:2876%eth0 bcast=fe80::ffff:ffff:ffff:ffff%eth0 netmask=ffff:ffff:ffff:ffff::
[2013/08/27 09:25:40.141655, 2] lib/interface.c:341(add_interface)
added interface wlan0 ip=192.168.1.35 bcast=192.168.1.255 netmask=255.255.255.0
[2013/08/27 09:25:40.141688, 2] lib/interface.c:341(add_interface)
added interface eth0 ip=10.42.0.1 bcast=10.42.0.255 netmask=255.255.255.0
[2013/08/27 09:25:40.141783, 0] smbd/server.c:1082(main)
standard input is not a socket, assuming -D option
[2013/08/27 09:25:40.147336, 2] smbd/server.c:815(smbd_parent_loop)
waiting for connections
[2013/08/27 09:25:40.151155, 2] rpc_client/cli_winreg_spoolss.c:896(winreg_create_printer)
winreg_create_printer: Skipping, SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Officejet_7500_E910__4C53E0_ already exists
[2013/08/27 09:25:40.151234, 2] smbd/server.c:301(remove_child_pid)
Could not find child 25727 -- ignoring
结束log.smbd
编辑这是最相关的日志:
2013/08/27 10:37:45.149211, 2] auth/auth.c:319(check_ntlm_password)
check_ntlm_password: Authentication for user [shok10a] -> [shok10a] FAILED with error NT_STATUS_WRONG_PASSWORD
但密码并没有错。
答案1
似乎没人能回答这个问题。经过一番仔细阅读后,似乎问题很可能与 OS X 如何使用 SAMBA(LM、NTLM、NTLMV2)验证密码有关。
由于有些 Mac 能够连接,而有些则不能,我决定简单地安装 Netatalk 并对所有 Mac 使用 AFP 协议。
虽然这会让管理变得有点麻烦,因为我必须担心两个文件共享系统的设置,但似乎运行良好。理想情况下,最好直接使用 SAMBA,但我读过的所有资料都说,我需要在 Mac 机器上运行特定脚本,以允许它们以纯文本形式传递密码(默认情况下,此功能是禁用的)。
所以,如果您遇到了这个问题,请查阅有关设置 Netatalk 的教程。无论如何,它可能比 Mac 端的 SAMBA 快一点。
更新:这是 Snow Leopard 的问题。由于 Apple 不再积极开发 AFP,因此较新版本的 OS X(Mavericks 等)原生使用 SAMBA。将我的所有机器升级到 Mavericks 后,我能够摆脱 AFP,现在所有机器都使用 SMB。