I am working in a primarily Windows environment.
I need to access a Windows shared drive which is known among my colleagues as "the L drive". Running net use on a Windows machine shows the UNC path of the shared drive:
Status Local Remote Network ------------------------------------------------------------------------------- L: \\ad.company.com\shared\Sites\BLAH Microsoft Windows Network Connecting with smbclient
I'm able to browse this shared drive using smbclient (version 4.19.5-Ubuntu) with a command like the following:
$ smbclient -g -U 'COMPANY/USERNAME%PASSWORD' \ //ad.company.com/Shared -D Sites/BLAH Adding --debuglevel 3, I'm able to verify from the verbose logs that smbclient is using normal/modern DNS-based host lookup (not NetBIOS), ntlmssp challenge-based authentication (not Kerberos), and connecting on port 445 (not the legacy port 139):
… Connecting to 10.0.12.34 at port 445 convert_string_handle: E2BIG: convert_string(UTF-8,CP850): srclen=29 destlen=16 error: No more room Connecting to 10.246.225.180 at port 139 Kinit for username@COMPANY to access SOME.OTHER.HOSTNAME failed: Cannot contact any KDC for requested realm Got challenge flags: Got NTLMSSP neg_flags=0x62898215 And indeed, I can make the connection start up little bit faster by adding these flags to the command line: smbclient -R host --port 445 --use-kerberos=off ….
Mounting with mount.cifs
Since I can browse this shared drive using smbclient, I ought to be able to mount it with mount.cifs (version 7.0).
So I try the following:
$ sudo mount --verbose -t cifs \ -o 'domain=COMPANY,username=USERNAME,prefixpath=Sites/BLAH,password=PASSWORD' \ '//ad.company.com/Shared' /mnt/l mount.cifs kernel mount options: ip=10.0.12.34,unc=\\ad.company.com\Shared,prefixpath=Sites/BLAH,user=USERNAME,domain=COMPANY,pass=******** mount error(126): Required key not available About 80% of the time I get error(126): Required key not available, and 20% of the time running an identical command I get error(2): No such file or directory.
I'm certain that the credentials are being accepted, because I get a different error(13): Permission denied if I use incorrect credentials.
I've tried adding various other options including:
- Adding
sec=ntlmsspto explicitly set the authentication method used. - Adding
vers=3,vers=2.1to try specific SMB versions. - Removing the
prefixpath=Sites/BLAH, so that I am mounting the top-level Windows share//ad.company.com/sharedrather than a subdirectory thereof. - Removing the
prefixpath, and adding it to the end of the complete UNC path, e.g.//ad.company.com/shared/Sites/BLAH; per the docs, this is simply a syntactic variant.
… but none of this makes any difference. I consistently get either Required key not available or No such file or directory.
I've checking the kernel log messages with dmesg, but they don't show anything other than the same error codes.
Question
What is smbclient doing that allows it to succeed where mount.cifs fails? How can I get mount.cifs to mount this share successfully?
Additional bits of information:
- There are other Windows shares (on other servers) that I can mount successfully with a similar command-line, and the same credentials.
- The variation in the error message from
mount.cifssuggests to me that there's some kind of race condition happening here.
Other sources consulted
- smbclient can access Windows share content, mount.cifs cannot: Similar description, but different problem. In this case, the
mount.cifssucceeds, but a specific directory within it cannot be accessed. - https://stackoverflow.com/questions/42363263: Very similar problem, but in that case Kerberos is being used, and the accepted solution does not appear relevant.
- https://github.com/NixOS/nixpkgs/issues/265521 (thanks to this comment: The symptoms are strikingly similar, but in my case replacing the hostname with any of the server's IP addresses makes no difference. Also, some of the commenters on the NixOS issue indicate that it's exclusive to kernel 6.6.3, and fixed in 6.6.3, while I'm on 6.6.87.2.
//ad.company.com/sharedvs//ad.company.com/Shared- I know windows in most part is case insensitive, but, it's still a difference in what you are doingsmbclientand withmount -t cifs, and they don't appear to affect the observed behavior. For example,smbclientstill works if I spell it assHaReD, andmount -t cifsstill fails in the same way.prefixpath=Sites/BLAH") and I get the same error(s) frommount.cifs: random variation betweenRequired key not availableorNo such file or directory. Added a few more details to clarify that I tried these already.dmesg? (might require CONFIG_CIFS_DEBUG to be set in kernel configuration)