[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Ubuntu MOUNT in FSTAB fails when passing credentials

Posted on 2011-10-25
17
Medium Priority
?
861 Views
Last Modified: 2013-11-15
This one is driving me up the wall.  

I am simply trying to mount a CIFS share into the /mnt directory of this Ubuntu 10.04.3 LTS host.  

From a command line, I can issue "mount -t cifs //<host ip>/media -o username=<user>,password=<password> /mnt/nasmedia"          This loads fine, the drive is mounted.   I can browse and list files.  Tells me that credentials , networking, etc...  are all working.  

I create a credentials file in /home/mike/ called smbauth.   I made sure there were no trailing <CR> in the file.

So I add this to /etc/fstab with:
//host ip/media   /mnt/nasmedia   cifs    credentials=/home/mike/smbauth,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0

I issue a 'mount -a' and get the following in dmesg:
[2412953.517721]  CIFS VFS: No username specified
[2412953.517868]  CIFS VFS: cifs_mount failed w/return code = -22

In Fstab if I replace the credentials file with username/password like this, it works:
//host ip/media /mnt/nasmedia cifs username=<username>,password=<password>,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0



So, why won't fstab read in the credentials file?      Any ideas?   Guesses?  
0
Comment
Question by:MikeKane
  • 7
  • 4
  • 3
  • +1
17 Comments
 
LVL 31

Expert Comment

by:farzanj
ID: 37028292
Here is an example for you.
/192.168.44.100/share   /path_to/mount   cifs
credentials=/path_to/.creds,_netdev,uid=client_user,gid=users   0 0

Open in new window


Make sure that the password file is readable by samba user.  Preferably it should be owned by the same user who runs the daemon
0
 
LVL 33

Author Comment

by:MikeKane
ID: 37028311
Good point about the rights.    For jollies, I CHMOD'ed the file to 777 just to try it and see if that made a difference.    

It did not.  

Same result:
[2414835.573366]  CIFS VFS: No username specified
[2414835.573511]  CIFS VFS: cifs_mount failed w/return code = -22



Its like the 'credentials' parameter is being completely ignored.  
0
 
LVL 31

Expert Comment

by:farzanj
ID: 37028325
It is just not the file permission only.  It is the whole path permission.  In your case, /home/mike/, both home and mike folders should also have execute permissions for everyone
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
LVL 33

Author Comment

by:MikeKane
ID: 37028338
Does the credentials file  need Execute (i.e. 700) or just read/write (i.e. 600)?  
0
 
LVL 31

Expert Comment

by:farzanj
ID: 37028379
File permissions totally depend upon who ones and who would use it.

Tell you what.  Become samba user, the user who runs the daemon.  Then do a cat on the /home/mike/smbauth file.  You should be able to do it successfully.
0
 
LVL 33

Author Comment

by:MikeKane
ID: 37029116
Pardon my ignorance, but how can I determine the user running the daemon?
0
 
LVL 10

Expert Comment

by:Pierre François
ID: 37029867
I should try to issue next command from the command line, before changing the /etc/fstab file:

mount -t cifs //<host ip>/media -o credentials=/home/mike/smbauth,iocharset=utf8,file_mode=0777,dir_mode=0777 /mnt/nasmedia

Open in new window


to see where the problem is: in /etc/fstab or in the syntax of the arguments of mount.
0
 
LVL 10

Expert Comment

by:Pierre François
ID: 37029895
Since the credentials file needs to protect a password, it is not aimed to have it set with 777 as permissions. I am not sure it is the case of mount.cifs, but I remember that some software refuse to use improperly protected credentials files. 600 are the typical permissions for such a file.

On Ubuntu, the mounted devices are owned by "root" and have "disk" as group. I think fhe deamon mounting file systems runs as root. It is more logical to locate such a file into the root files space, somewhere in /etc/ or /root/ rather than in /home/mike/.

P.S. If you try to mount filesystems from the command line, I am sure you do it with "sudo".
0
 
LVL 33

Author Comment

by:MikeKane
ID: 37031467
So I 'sudo -i' to root.   I've tried the credentials file in both \home\mike\ and in \root\.    I tried it as .smbcredentials and as non-hidden smbcredentials.   I've tried it with 600 and 700 permissions.      The owner is root:root and I can cat the file from command line as expected.  



So from command line, I try
mount -t cifs //<ip address>/media -o credentials=/root/.smbauth,iocharset=utf8,file_mode=0777,dir_mode=0777 /mnt/nasmedia

This results in
mount: wrong fs type, bad option, bad superblock on //192.168.10.5/media,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

dmesg|tail shows:
[2469572.065872]  CIFS VFS: No username specified
[2469572.066019]  CIFS VFS: cifs_mount failed w/return code = -22

Obviously, its not reading in the file or doesn't understand the contents, or has bad username.  

So it doesn't look like its a fstab vs command line issue.      The error happens at either.    


When I specify the credentials, within either fstab or at command line, there is no problem.  So I know the credentials to the remote host are correct.  

That tells me its either MOUNT not able to read the file, interpret the file, or find the file.   (anyone else have thoughts here)  

The contents of the file look like:
root@base:~# cat /root/.smbauth
username=<username>
password=<password>
root@base:~#

Just to make sure there were no other characters, I recreated the credentials file from command line too.  

Thoughts?    





0
 
LVL 19

Accepted Solution

by:
xterm earned 2000 total points
ID: 37032050
You need the program "mount.cifs" which is provided by the smbfs package in order to do a system mount of the directory rather than your typical manual mount.   It will work after you do this:
sudo apt-get install smbfs

Open in new window

0
 
LVL 19

Expert Comment

by:xterm
ID: 37032061
BTW, it drove me up the wall trying to figure that one out too, because my system did exactly the same thing - I found the answer here http://thinkinginsoftware.blogspot.com/2010/10/cifs-vfs-no-username-specified.html.

For what it's worth, in Fedora which I run I had to do "yum install cifs-utils" to provide the file mount.cifs
0
 
LVL 33

Author Comment

by:MikeKane
ID: 37032323
Awesome.   That was it.    Once I installed the smbfs package, the credentials file was read without issue.    
0
 
LVL 33

Author Closing Comment

by:MikeKane
ID: 37032332
Awesome.   That was it.    Once I installed the smbfs package, the credentials file was read without issue.    

Very odd issue since I thought I read that smb was depreciated and replaced with cifs.
0
 
LVL 10

Expert Comment

by:Pierre François
ID: 37033043
You will have seen that the solution appeared after you tried to mount from the command line. The strategy is to divide a problem in several subproblems.

The error message you got, i.e. "for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program", made it clear to xterm that you were missing the program "mount.cifs".
0
 
LVL 19

Expert Comment

by:xterm
ID: 37033103
Actually, I never noticed that post pfrancois - good eyes.  I was actually just working off the author's original post, and tried to replicate it on my own system, and then googled the error :)
0
 
LVL 33

Author Comment

by:MikeKane
ID: 37034286
I saw the error message about missing the mount.helper but what threw me was the fact that I *could* do a cifs mount it I provided the credentials inline.       Only when I tried to read it from a file, did it fail.    I did not know that the smbfs package was required for that functionality.  

0
 
LVL 10

Expert Comment

by:Pierre François
ID: 37036375
@Mike: I understand your comment. It is indeed puzzling...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you sitting there reading this and wondering how to get started with Linux? It almost seems like picking the right Linux distribution is about like picking the right college or buying a new car if you read some of the article out there. Relax… l…
If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question