16

I'm having trouble mounting a share on my XenServer (5.6 FP1). From the command line I try:

mount.cifs //server/share /mnt/share -o credentials=credfile

The contents of credfile is:

username=Administrator
password=What@zR\!p3s

When I run the above mount command I get "Access Denied". However if I run the following command it works:

mount.cifs //server/share /mnt/share -o username=Administrator,password=What@zR\!p3s

Please note the "\" is to escape the bang and I've tried this with and without it in the credentials file. Any suggestions?

David George
  • 888
  • 1
  • 9
  • 21

7 Answers7

13

I have the same problem because my password contain comma symbol (i.e. "PASS,WORD"):

$ sudo mount -t cifs -o domain=mydomain,username=myuser,password=PASS,WORD //server/share localfolder
mount error(22): Invalid argument
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

At first, you should try enable verbose mode (--verbose option):

$ sudo mount -t cifs -o domain=mydomain,username=myuser,password=PASS,WORD //server/share localfolder --verbose
mount.cifs kernel mount options: ip=172.30.91.137,unc=\\server\share,WORD,user=myuser,,domain=mydomain,pass=********

Here I see my problem. Comma breaks all stuff. Solution is use credential file. What is written in man 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

This is preferred over having passwords in plaintext in a shared file, such as /etc/fstab. Be sure to protect any credentials file properly.

Create this file any way you like:

$ cat > cifs.credo
username=myuser
password=PASS,WORD
domain=mydomain

and use (--verbose can be omitted)

$ sudo mount -t cifs -o credentials=path/to/cifs.credo //server/share localfolder --verbose
mount.cifs kernel mount options: ip=172.30.91.137,unc=\\server\share,user=myuser,,domain=mydomain,pass=********

No problem with password.

Maxim Suslov
  • 231
  • 2
  • 3
6

A common issue with old versions of mount.cifs was that the newline at the end of the file was kept as part of the password.

So you shouldn't need to escape, and should try to rewrite this file without a trailing newline.

To do so in vim, use :set noeol binary before saving. You can check that there is no trailing newline with xxd credfile, and confirm that it does not finish with 0a.

If this doesn't work, I'll have to check your exact codebase. Which package (distribution, version and release) or source (archive name) are you using for cifs-utils?

Pierre Carrier
  • 2,607
  • 17
  • 28
1

Have you tried removing the slash? completely? I don't believe the credentials file should need to be escaped at all. It needs to be escaped on the shell because the shell is interpreting the characters, not the mount.cifs command.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
1

Another thing to try is to type the special character twice... I had a password with a $ in it, and had to replace it with $$. However, I'm currently having issues with the carrot: '^'

Alex
  • 11
  • 1
1

For mount.cifs version 4.5 the following worked for me: credentials in order of domain, username, password, no newline after the password, no escaping of special characters or quotes.

lessnoise
  • 11
  • 1
1

This was very helpful! My problem was an extra space in the "credential" file that the --verbose showed me

mount.cifs kernel mount options: ip=10.77.180.65,unc=\\odxwtdsa.naoxy.com\TDS_BODS_Fileshare,user=srv-tdsadm,domain=NAOXY ,pass=********
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
[root@odylztxz drpadm]#

Did a "vi" on the credentials file and :set list Saw the extra trailing blank. Removed it. Tried again. Note the "blank" is now gone.

[root@odylztxz ~]# mount.cifs  -o credentials=/etc/.credentials,uid=1002,gid=200,file_mode=0x777,noperm //odxwtdsa.naoxy.com/TDS_BODS_Fileshare /TDS_BODS_FS --verbose
domain=NAOXY

mount.cifs kernel mount options: ip=10.77.180.65,unc=\\odxwtdsa.naoxy.com\TDS_BODS_Fileshare,file_mode=0x777,noperm,uid=1002,gid=200,user=srv-tdsadm,domain=NAOXY,pass=********
[root@odylztxz ~]# df -h
Filesystem                               Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root                     50G  4.9G   45G  10% /
devtmpfs                                  16G     0   16G   0% /dev
tmpfs                                     16G     0   16G   0% /dev/shm
tmpfs                                     16G   76M   16G   1% /run
tmpfs                                     16G     0   16G   0% /sys/fs/cgroup
/dev/sdb1                                100G   11G   90G  11% /orasoft
/dev/sdc1                                100G   33G   68G  33% /oxyswap
/dev/sda2                                497M  214M  284M  43% /boot
/dev/mapper/rhel-var                     5.5G  1.2G  4.3G  22% /var
10.77.25.114:/GEN_BACKUP_DBS             5.8T  4.8T  945G  84% /backup
10.77.25.114:/GEN_MEDIA                  380G  319G   62G  84% /sap_media
10.77.25.114:/ORA_ZTX_SAPMNT              95G   12M   95G   1% /sapmnt
10.77.25.113:/ORA_ZTX_USR_SAP             95G   13M   95G   1% /usr/sap
10.77.25.113:/GEN_TRANS                  190G   26M  190G   1% /trans
tmpfs                                    3.2G   40K  3.2G   1% /run/user/4200
tmpfs                                    3.2G     0  3.2G   0% /run/user/3501
//odxwtdsa.naoxy.com/TDS_BODS_Fileshare  750G  578G  173G  78% /TDS_BODS_FS
[root@odylztxz ~]#
Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
RickS
  • 11
  • 1
0

Try quoting it.

I.e.,

password="What@zR!p3s"

And I hope that's not really your password. If it is, you now need to change it.

bahamat
  • 6,193
  • 23
  • 28
  • No that is not a real password. Second, I've already tried both suggestions with same result. Have also tried literal quotes, ie. >> ' – David George Sep 08 '11 at 16:01