mount.cifs 不能使用 smbclient 所使用的相同憑證文件

mount.cifs 不能使用 smbclient 所使用的相同憑證文件

我正在嘗試將 NetApp CIFS 共享安裝到我們的一台伺服器上,但我不斷將“權限被拒絕”打印到 stderr 並NT_STATUS_WRONG_PASSWORD打印到正在運行的dmesg.

root@xxxehpvld05 ~ $ mount.cifs -vv //zhp-nas.xxx.com/perspectives /mnt/secure/cifs -o credentials=/etc/cifs.creds
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
root@xxxehpvld05 ~ $ dmesg | tail
CIFS VFS: cifs_mount failed w/return code = -13
Status code returned 0xc000006a NT_STATUS_WRONG_PASSWORD
CIFS VFS: Send error in SessSetup = -13
CIFS VFS: cifs_mount failed w/return code = -13
Status code returned 0xc000006a NT_STATUS_WRONG_PASSWORD
CIFS VFS: Send error in SessSetup = -13
CIFS VFS: cifs_mount failed w/return code = -13
Status code returned 0xc000006a NT_STATUS_WRONG_PASSWORD
CIFS VFS: Send error in SessSetup = -13
CIFS VFS: cifs_mount failed w/return code = -13

但是,使用相同的憑證文件,該smbclient命令可以正常工作:

root@xxxehpvld05 ~ $ smbclient -L //zhp-nas.xxx.com/perspectives -A /etc/cifs.creds
Domain=[XXX] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]

        Sharename       Type      Comment
        ---------       ----      -------
        IPC$            IPC       Remote IPC
        ZHPSubmit-dev   Disk
    [...snip...]

似乎如果一個有效,另一個也應該有效,特別是因為憑證檔案也指定了網域名稱。

答案1

沒有更多信息,我不能肯定地說,但我在連接到運行舊協議版本的舊 Windows 伺服器時看到了這個問題。請記住,CIFS 被視為 SMB 的「方言」(類型)。還有其他類型,較舊的設定不使用 CIFS。

基本上就像是說兩個人在說話。一種西班牙語和一種英語,你試圖強迫說英語的人聽懂西班牙語,但他顯然聽不懂。

SMBclient 使用不同的方言進行安全協商。 (或至少檢測到不同)。

嘗試

mount -t cifs //路徑/事物/ /mount/point -o 使用者名稱=用戶,密碼=pass,秒=ntlm

看看會發生什麼事。 (sec=ntlm是重要部分)

答案2

透過使用命令,我發現了一個可能的原因:

從 smbclient 的手冊頁:

   -A|--authentication-file=filename
       This option allows you to specify a file from which to read the
       username and password used in the connection. The format of the file is

           username = <value>
           password = <value>
           domain   = <value>

       Make certain that the permissions on the file restrict access from
       unwanted users.

從 mount.cifs 的手冊頁:

   credentials=filename
       specifies a file that contains a username and/or password and
       optionally the name of the workgroup. The format of the file is:

          username=value
          password=value
          domain=value

然後,我創建了兩個憑證文件,一個帶有空格,如第一個片段所示,另一個沒有空格,並將它們命名為credscreds.spacy

大對決:

creds文件:

mount.cifs -vvv //host/path /local/path -o credentials=/path/creds

良好的沉默,沒有錯。

creds.spacy文件:

# mount.cifs -vvv //host/path /local/path -o credentials=/path/creds.spacy
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

顯然,您的憑證檔案包含空格,mount.cifs 無法理解這些空格。

另外,smbclient如果有空格也沒關係。credscreds.spacy沒有引起任何抱怨。

答案3

我今天在嘗試掛載共享時發現的另一種可能性是支援smbmountusername=DOMAIN\\user網域中的使用者提供為憑證的語法。

為了使mount.cifs( 和mount -t cifs) 工作,必須單獨提供這兩個:-o username=user,password=pass,dom=DOMAIN

答案4

正如 user55518 所解釋的,即使您沒有看到它們,您的憑證檔案中也可能有空格。如果您在 Windows 上編輯了憑證文件,則可能會\r在行尾編輯並引發錯誤 13。

相關內容