天天看點

Unable to mount CIFS share on Linux: mount error(13): Permission denied (cifs_mount failed w/return

      有多種方法可以在Linux用戶端上裝載CIFS/Samba共享 、windows共享。然而,有些教程已經過時了,而且完全錯誤。我剛剛遇到了一個(愚蠢的)裝載錯誤的情況。

很多教程Linux裝載 windows共享檔案夾的  cifs文法:

[root@xtwh-test-01 ~]# mount -t cifs //10.99.101.102/Microsoft/ /mnt/anysharelog/ -o username="mydomain\myusername",password="mypassword",vers=1.0,ro

mount error(13): Permission denied

不幸的是,dmesg中的額外輸出無助于解決問題:

[root@xtwh-test-01 ~]#dmesg

[... ...]

[43128138.860530] Status code returned 0xc000015b NT_STATUS_LOGON_TYPE_NOT_GRANTED

[43128138.860537] CIFS VFS: Send error in SessSetup = -13

[43128138.861425] CIFS VFS: cifs_mount failed w/return code = -13

在出現其他嘗試和錯誤(并從曆史記錄中查找最近的共享裝載)後,問題原來是user=domain\myuser文法。這種将域/工作組和使用者名相結合的方式已經不起作用了。

注意:選項中同時接受user=和username=。

而是使用:

[root@xtwh-test-01 ~]# mount -t cifs "//10.99.101.102/Microsoft" /mnt/anysharelog/ -o "user=myusername,password=mypassword,workgroup=mydomain"

裝載成功

Of course the password should not be used on the command line, so for the final (and automatic) mount of the share use the following entry in /etc/fstab:

root@focal:~# cat /etc/fstab

[...]

# Mount CIFS share from server

//server/Share /mnt cifs rw,relatime,vers=3.1.1,credentials=/etc/samba/servershare.conf,uid=0 0 0

Where /etc/samba/servershare.conf contains the credentials:

root@focal:~# cat /etc/samba/servershare.conf

user=myuser

password=secret

domain=DOMAIN

繼續閱讀