Re-opening the thread 16 years later. I encountered a similar - but even
weirder - behaviour on Lubuntu 26.04.

I document three ways to set up on-demand connection to samba share. 1st
works fully (requiring 2 passwords each time), 2nd works with the weird
caveat (requiring remote password), 3rd doesn't seem to work (but if it
worked, it wouldn't require typing any password).

I hope this can be useful to somebody, and perhaps it even helps fix or
better document the CIFS mount.

[Please replace SERVER, REMOTEDIR, MNTPNT, dominecf, USER, 12345 with
your own strings.]


(CASE 1) To get through network, I set up SSH connection:

    ssh -L 4450:localhost:445 USER@SERVER -N

Then I can connect explicitly, entering local+remote passwords:

    sudo mount -t cifs //localhost/REMOTEDIR /home/dominecf/MNTPNT/  -o 
username=USER,vers=3.0,port=4450,uid=$(id -u),gid=$(id 
-g),file_mode=0644,dir_mode=0755
    
This works 100%, but it is awkward because of the two passwords. 

(CASE 2) To remove the need for `sudo` password, I can add a new
/etc/fstab entry:

//localhost/REMOTEDIR /home/dominecf/MNTPNT cifs
noauto,user,username=USER,vers=3.0,port=4450,uid=1234,gid=1234,file_mode=0644,dir_mode=0755

This entry can be then directly mounted.

One important observation: there may be *NO TRAILING SPACES* in fstab.
The line may or may not contain the " 0 0" entries, but again, never let
whitespace after them. Otherwise you get  "mount error(13): Permission
denied" and dmesg tells you nothing about the real reason either:

[109988.383664] CIFS: Attempting to mount //localhost/REMOTEDIR
[109988.791938] CIFS: Status code returned 0xc000006d STATUS_LOGON_FAILURE
[109988.791983] CIFS: VFS: \\localhost failed to create a new SMB session with 
Unknown: -13
[109988.792045] CIFS: VFS: cifs_mount failed w/return code = -13

So the quite good solution here is to "mount MNTPNT" and always enter
remote password. It's also safer than case 3 because no credentials are
stored anywhere.


(CASE 3) In my unsuccessful attempt of logging in entirely without entering a 
password, I took a minor security risk and make a ~/.smbcreds file containing 
my remote username and password, setting its permissions=600 as a little 
privacy measure. E.g.:

  username=USER
  password=12345
  
Then I changed the corresponding line in /etc/fstab to use the .smbcreds file, 
e.g.,

//localhost/REMOTEDIR /home/dominecf/MNTPNT cifs
noauto,user,credentials=/home/dominecf/.smbcreds,vers=3.0,port=4450,uid=1000,gid=1000,file_mode=0644,dir_mode=0755

and no matter what I tried, I got the error 13 as above.

So the second important observation is that cifs mount failed *always*
when pointed to credentials file. I am pretty much sure I used the
correct username and password both when logging in, and when saving the
file. It would be useful if somebody could replicate this behaviour, and
perhaps get some debugging.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/543094

Title:
  mount error 13 - permisison denied when mounting samba shares on
  ubuntu server using cifs

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/samba/+bug/543094/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to