16

I’m having a problem with fstab on Server 18.04. I’m trying to mount a number of Windows Server network shares. If I put the username and password into each line of fstab and do sudo mount -a, it works fine. However, when I try to use a “credentials” file, it all goes pear-shaped.

So this:

//server/share /mount/point cifs ro,auto,user=user,password=password 0 0

…works fine.

However, if I try this:

//server/share /mount/point cifs ro,auto,credentials=/etc/.smbcredentials 0 0

…with .smbcredentials containing the following:

user=username  
password=password  
domain=domain  

…this does not work. sudo mount -a -v outputs the following:

/ : ignored  
/boot/efi : already mounted  
none : ignored  
domain=mydomain  
,prefixpath=Projects/XYZ,pass=********.168.1.10,unc=\server\share,user=username  
mount error(13): Permission denied  
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

168.1.10 is the partial IP address of the server on which the shares that I want to mount are located. It appears that the password is being concatenated onto the IP of the server.

So, what am I doing wrong? Any help would be much appreciated.

threnody
  • 161
  • 1
  • 1
  • 3

4 Answers4

12

My working credentials file is located in my ~ folder and looks like this

username=[username]
password=[password]

Its permissions are -rw------- and it is owned by my user.

The corresponding fstab line is

//[URL]/[sharename] /media/[mountpoint] cifs vers=3.0,credentials=/home/[username]/.sharelogin,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=[username],gid=[username],nofail 0 0

I don't use "domain" but that doesn't mean that you don't need it.

8

Had same issue, check for errors with:

tail -f /var/log/kern.log

-- > kernel: [ 7917.935203] CIFS VFS: No username specified

$ sudo apt install cifs-utils

Fixed it for me..

JPronk
  • 81
0

I was having trouble mounting my QNAP NAS Samba share on Ubuntu 18.04 with a credentials file. Here's what worked for me after trying on and off for months.

  1. Find your Ubuntu username and create an identically named user with the password of your choice on your QNAP nas with the appropriate R/W permissions to your shared folder. So my username for Ubuntu is username so I created a user on QNAP called username and generated a random password with LastPass.
  2. Create a file to hold the Samba login credentials: nano ~/.samba_credentials
  3. Add the following lines:
username=your_shared_linx_and_qnap_username
password=the_qnap_user_password_you_chose
domain=WORKGROUP

Here's how mine looks:

username=username
password=last_pass_password
domain=WORKGROUP

The domain option might be optional but the default Windows 10 workgroup is WORKGROUP so this should work as long as you didn't change it. And if you did change it you probably know what a workgroup is and what value you changed it to.

  1. Create the folder where your share will mount locally. mkdir /media/username/storage
  2. Then edit your /etc/fstab file to auto-mount the QNAP Samba share via CIFS:
  3. //nas1da09d.local/files /media/username/storage cifs credentials=/home/username/.samba_credentials,uid=username,noperm,rw 0 0
-1

When mounting several smb drives with same credentials you have to create one credential file per mount. In other words, you can not use one credential file for several mounts.

Create a new file for each mount

sudo nano /etc/.smbcredentials1
sudo nano /etc/.smbcredentials2
sudo nano /etc/.smbcredentials3

add your credentials to each file

username=username
password=password
domain=WORKGROUP

then chmod the files for protection

sudo chmod 0600 .smbcredentials1 .smbcredentials2 .smbcredentials3 

then use each file as credantials for each mount sudo nano /etc/fstab

//server/share /mount/point cifs ro,auto,credentials=/etc/.smbcredentials1 0 0
//server/share /mount/point cifs ro,auto,credentials=/etc/.smbcredentials2 0 0
//server/share /mount/point cifs ro,auto,credentials=/etc/.smbcredentials3 0 0

then mount

sudo mount -a -v

this will probably solve your issue.