在 Linux 上永久挂载 Samba 版本 4 共享

在 Linux 上永久挂载 Samba 版本 4 共享

我想在新设置的 Linux Mint 20.1 系统上永久安装 Samba 共享。我在 FreeNAS 11.3 上运行 Samba 版本 4.10。

我可以在当前会话中挂载在终端中运行(来自本手册):

sudo mount -t cifs //net-host/share /mnt/share -o user=user,password=mypw,domain=lan

永久安装我尝试编辑该etc/fstab文件。我添加了以下行(来自本手册):

//net-host/share /mnt/share cifs username=user,password=mypw, 0 0 

并保存fstab

然后在终端:

(base) user@machine:~$ sudo mount -a
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
(base) user@machine:~$ dmesg | tail
...
[ 3680.727542] CIFS: Attempting to mount //net-host/share
[ 3680.727561] No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.
[ 3680.751016] Status code returned 0xc000006d STATUS_LOGON_FAILURE
[ 3680.751027] CIFS VFS: \\freenas Send error in SessSetup = -13
[ 3680.751040] CIFS VFS: cifs_mount failed w/return code = -13
(base) user@machine:~$ 

我们尝试了很多其他选择fstab文件中:

  • vers=1.0,日志中出现以下错误dmesg
[ 4583.692974] CIFS VFS: cifs_mount failed w/return code = -95
  • vers=2.0,或者vers=3.0,在日志中产生以下错误dmesg
[ 4666.975227] Status code returned 0xc000006d STATUS_LOGON_FAILURE
[ 4666.975235] CIFS VFS: \\freenas Send error in SessSetup = -13
[ 4666.975250] CIFS VFS: cifs_mount failed w/return code = -13
  • vers=4.0,日志中出现以下错误dmesg
[ 4888.934509] CIFS VFS: Unknown vers= option specified: 4.0
  • sec=ntlm,日志中出现以下错误dmesg
[ 4160.566932] No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.
[ 4160.587967] CIFS VFS: Unable to select appropriate authentication method!
[ 4160.587970] CIFS VFS: \\net-host Send error in SessSetup = -22
[ 4160.587989] CIFS VFS: cifs_mount failed w/return code = -2
  • uid=1002,
[ 5923.542766] No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.
[ 5923.566847] Status code returned 0xc000006d STATUS_LOGON_FAILURE
[ 5923.566857] CIFS VFS: \\freenas.local Send error in SessSetup = -13
[ 5923.566868] CIFS VFS: cifs_mount failed w/return code = -13
  • uid=1002,vers=1.0,
[ 6195.633461] CIFS VFS: cifs_mount failed w/return code = -95
  • x-systemd.automount, vers=3.0,
[ 6504.718290] Status code returned 0xc000006d STATUS_LOGON_FAILURE
[ 6504.718298] CIFS VFS: \\freenas.local Send error in SessSetup = -13
[ 6504.718309] CIFS VFS: cifs_mount failed w/return code = -13
  • dir_mode=0777,file_mode=0777,vers=3.0,
[ 6623.955689] Status code returned 0xc000006d STATUS_LOGON_FAILURE
[ 6623.955700] CIFS VFS: \\freenas.local Send error in SessSetup = -13
[ 6623.955717] CIFS VFS: cifs_mount failed w/return code = -13

我们尝试过访问服务器的不同方式通过更改文件中的行fstab

  • 按 IP://192.168.0.XX/share /mnt/share cifs username=user,password=mypw,vers=1.0, 0 0
[ 5465.946197] CIFS VFS: cifs_mount failed w/return code = -95
  • 使用.local://net-host.local/share /mnt/share cifs username=user,password=mypw,vers=1.0, 0 0
[ 5848.179532] CIFS VFS: cifs_mount failed w/return code = -95

答案1

原来密码拼写错误。

因此插入以下任意一行都fstab可以:

//net-host/share /mnt/share cifs username=user,password=mypw 0 0 

或者

//net-host/share /mnt/share cifs credentials=/home/user/.smbcredentials 0 0 

文件.smbcredentials内容如下:

username=user
password=mypw

无需指定其他选项。事实上,对于我来说,设置时它不起作用sec=ntlm

PS:请确保用适当的文件路径替换net-hostsharemnt确保您的用户名和密码拼写正确。

相关内容