# [Q+A] samba mount cifs error 13 21 Permission denied

## doublehp

After a lot of googling, I could not find any real answer to my Samba issue. I come to publish the reason, and the solution to what happenned to me. Hope future generation will find my story usefull.

Aim: mount some Samba server on my Linux workstation. Details are irrelevant. Various error numbers can occur: 11, 13 , 21 ... the solution is always the same. I learnt how to use Samba in late 1999; by that time, we needed to quote passwords inside double quotes, and the password was written in clear text in fstab; there were more secure alternatives available, but they were too heavy to use for me; the easy and simple way was enough for my laptop. As I was quoting password, I did the same to login username.

When doing exactly the same thing today, it just does not do it.

Note that the username can be assigned to variable user or username depending on where you are (fstab, cmd line, credentials), and can be given under the form username, or, workgroup/username, depending on many things I will not detail in here.

```
uranus ~ # tail -n1 /etc/fstab

//192.168.0.1/sdcard /mnt/sensation-sdcard   cifs    ro,user,noauto,user="u",password="p"      0 0

uranus ~ #

uranus ~ # mount /mnt/sensation-sdcard

mount error(13): Permission denied

Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

uranus ~ #

uranus ~ # tail /var/log/messages

Aug  7 17:52:52 uranus kernel: Status code returned 0xc000006d NT_STATUS_LOGON_FAILURE

Aug  7 17:52:52 uranus kernel: CIFS VFS: Send error in SessSetup = -13

Aug  7 17:52:52 uranus kernel: CIFS VFS: cifs_mount failed w/return code = -13

uranus ~ #

# ... 

uranus ~ # tail -n1 /etc/fstab

//192.168.0.1/sdcard  /mnt/sensation-sdcard   cifs    ro,user,noauto,credentials=/etc/fstab.credentials.txt   0 0

uranus ~ #

uranus ~ # cat /etc/fstab.credentials.txt

username="u"

password="p"

domain=WORKGROUP

uranus ~ #

uranus ~ # mount /mnt/sensation-sdcard

mount error(13): Permission denied

Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

uranus ~ #

# at this point, I get angry, and copy paste my first fstab line into console: literaly, just copy paste the blocks in the right order: hand type ONLY this: mount -t -o ... the 4 other blocks are copy pasted to be 100% sure we use the same text:

uranus ~ # mount -t cifs -o ro,user,noauto,user="u",password="p" //192.168.0.1/sdcard /mnt/sensation-sdcard

uranus ~ #

# WHAT THE HELL ??? let's see details.

uranus ~ # umount /mnt/sensation-sdcard

uranus ~ #

uranus ~ # mount -v -t cifs -o ro,user,noauto,user=u,password="p" //192.168.0.1/sdcard /mnt/sensation-sdcard

mount.cifs kernel mount options: unc=//192.168.0.1\sdcard,ver=1,ro,noexec,nosuid,nodev,noauto,user=u,ip=192.168.0.1,pass=********

uranus ~ #

uranus ~ # umount /mnt/sensation-sdcard

uranus ~ #

uranus ~ # mount -v /mnt/sensation-sdcard

Domain WORKGROUP

mount.cifs kernel mount options: unc=//192.168.0.1\sdcard,user="u",domain=WORKGROUP,ver=1,ro,noexec,nosuid,nodev,noauto,credentials=/etc/fstab.credentials.txt,ip=192.168.0.1,pass=********

mount error(13): Permission denied

Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

uranus ~ #

# and when we revert to clear text:

uranus ~ # mount -v /mnt/sensation-sdcard

mount.cifs kernel mount options: unc=//192.168.0.1\sdcard,ver=1,ro,noexec,nosuid,nodev,noauto,user="u",ip=192.168.0.1,pass=********

mount error(13): Permission denied

Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

uranus ~ #

```

Do you see the difference between the working line, and the non working one ?

When you quote the username in fstbab or credentials, the quotes are sent to server. When you use the same quotes on command line to feed mount -o, they are not. BUT, using quotes on password IS fine and accepted ... in both cases !!!

Hope this helps. Hope Google will record this fur future times.

I wonder if this is a bug, and at which layer the bug lays. I have lost hours and days and weeks on not understanding why some computers could mount a given server, whereas different computer with different Linux distro could NOT ... using the same mount command, or same fstab line.

Quote the password, not the login.

Edit:

working fstab:

```
//192.168.0.1/sdcard  /mnt/sensation-sdcard   cifs    rw,noauto,username=u,password=p   0 0

//192.168.0.1/sdcard /mnt/sensation-sdcard   cifs    ro,user,noauto,credentials=/etc/fstab.credentials.txt   0 0

```

Working credential:

```
uranus ~ # cat /etc/fstab.credentials.txt

username=u

password=p

domain=WORKGROUP

uranus ~ #
```

Anything quoted will fail, even password. Good luck to those who love having *very* special chars in their passwords.

----------

## Hu

 *doublehp wrote:*   

> When you quote the username in fstbab or credentials, the quotes are sent to server. When you use the same quotes on command line to feed mount -o, they are not. BUT, using quotes on password IS fine and accepted ... in both cases !!!

 When you used quotes on the command line, the shell ran the command without the quotes.  I suspect that the code is smart enough to strip quotes on the password, but not on the username.  Your password probably does not contain any characters which require quoting, so the quote-stripped mount run by the shell worked.

----------

