Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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?

share|improve this question

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?

share|improve this answer

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=,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:


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

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=,unc=\\server\share,user=myuser,,domain=mydomain,pass=********

No problem with password.

share|improve this answer

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: '^'

share|improve this answer

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.

share|improve this answer
Yeah but that didn't work for me, thanks @lessnoise – David George Jul 24 '12 at 16:11

Try quoting it.



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

share|improve this answer
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 8 '11 at 16:01

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.

share|improve this answer
Yes, I've also tried it without the backslash in the credentials file. And I still get the access denied error. – David George Sep 9 '11 at 14:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.