You are not logged in.

#1 2026-05-27 20:10:18

Iriomote
Member
Registered: 2013-11-10
Posts: 32

[Solved] Mounting samba share with credentials-file failes

Hello to you!

Mounting network drives in Linux is like some form of black magic to me. Despite using Linux for so long I never could get a understanding in this subject.
I'm trying to put my credentials for my network drives in a separate file instead of having them in the fstab. But I can't get it to work.

Before my fstab looked like this:

//10.10.10.10/data-files	/home/iriomote/data	cifs uid=iriomote,gid=iriomote,username=iriomote,password=password123,noauto,x-systemd.automount,users,_netdev 0 0
//10.10.10.10/data-video	/home/iriomote/video	cifs uid=iriomote,gid=iriomote,username=iriomote,password=password123,noauto,x-systemd.automount,users,_netdev 0 0

This worked fine for me. But if I change my fstab like this it does not work anymore:

//10.10.10.10/data-files	/home/iriomote/data	cifs uid=iriomote,gid=iriomote,credentials=/.credentials,noauto,x-systemd.automount,users,_netdev 0 0
//10.10.10.10/data-video	/home/iriomote/video	cifs uid=iriomote,gid=iriomote,credentials=/.credentials,noauto,x-systemd.automount,users,_netdev 0 0

The path "/.credentials" is correct. I suspected file permission issues or problems with the availability of the /home mountpoint. For testing purposes I made the file readable by anyone.
The content is this:

iriomote@desktop ~$ cat /.credentials
username=iriomote
password=password123

findmnt:

root@desktop ~$ findmnt
...
├─/home                      /dev/mapper/vg-home
│ │                                         ext4            rw,relatime,lazytime,discard,commit=120
│ ├─/home/iriomote/data       systemd-1      autofs          rw,relatime,fd=70,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=16447
│ └─/home/iriomote/video      systemd-1      autofs          rw,relatime,fd=74,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=16453

This tells me, that something has mounted. But if I look in my home directory it looks like this:

iriomote@desktop ~$ ls -l /home/iriomote
total 32224
...
drwxr-xr-x  2 root    root           0 May 27 21:39  data
...
-rw-r--r--  1 iriomote iriomote  93K Apr  6  2022  raid.png
...
drwxr-xr-x  2 root    root       0 May 27 21:39  video
...
-rw-r--r--  1 iriomote iriomote 915K Mar 31  2021  wh_01.png

The mount points are now owned by root and I cannot access them. And the size is 0 Byte which is strange.

iriomote@desktop ~$ ls -l /home/iriomote/data
ls: cannot open directory '/home/iriomote/data': No such device

dmesg:

root@desktop ~# dmesg
...
[  519.764711] CIFS: enabling forceuid mount option implicitly because uid= option is specified
[  519.764714] CIFS: enabling forcegid mount option implicitly because gid= option is specified
[  519.764715] CIFS: Attempting to mount //10.10.10.10/data-files
[  519.777976] CIFS: VFS: cifs_mount failed w/return code = -13
[  519.778026] CIFS: enabling forceuid mount option implicitly because uid= option is specified
[  519.778028] CIFS: enabling forcegid mount option implicitly because gid= option is specified
[  519.778029] CIFS: Attempting to mount //10.10.10.10/data-video
[  519.787649] CIFS: VFS: cifs_mount failed w/return code = -13

Last edited by Iriomote (2026-05-28 15:32:05)

Offline

#2 2026-05-28 06:19:33

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,673

Re: [Solved] Mounting samba share with credentials-file failes

This tells me, that something has mounted.

No, tells you something will be mounted when trying to access the path.

stat /.credentials

What happens if you "chmod ugo+r" that?

Online

#3 2026-05-28 12:15:10

Iriomote
Member
Registered: 2013-11-10
Posts: 32

Re: [Solved] Mounting samba share with credentials-file failes

seth wrote:

This tells me, that something has mounted.

No, tells you something will be mounted when trying to access the path.

stat /.credentials

What happens if you "chmod ugo+r" that?


Thank you for your time.

root@desktop ~#ls -la /.credentials 
-rwxrwxrwx 1 iriomote iriomote 36 May 27 20:54 /.credentials
root@desktop ~# chmod ugo+r /.credentials 
root@desktop ~#ls -la /.credentials 
-rwxrwxrwx 1 iriomote iriomote 36 May 27 20:54 /.credentials
root@desktop ~# stat /.credentials
  File: /.credentials
  Size: 36              Blocks: 8          IO Block: 4096   regular file
Device: 253,2   Inode: 9156        Links: 1
Access: (0777/-rwxrwxrwx)  Uid: ( 1000/ iriomote)   Gid: ( 1000/ iriomote)
Access: 2026-05-27 21:38:45.831106831 +0200
Modify: 2026-05-27 20:54:09.567820028 +0200
Change: 2026-05-28 14:11:14.696603543 +0200
 Birth: 2026-05-27 21:38:42.700098508 +0200
root@desktop ~#

The behavior didn't change.

Offline

#4 2026-05-28 14:06:19

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,673

Re: [Solved] Mounting samba share with credentials-file failes

Because the permissions haven't - I could imaging cifs complaining this way because the file is completely unprotected => https://wiki.archlinux.org/title/Samba# … _passwords

Online

#5 2026-05-28 15:31:29

Iriomote
Member
Registered: 2013-11-10
Posts: 32

Re: [Solved] Mounting samba share with credentials-file failes

Okay, I got it to work now. It was a classic case of user error.

I was missing the smbclient package. After I installed it, it works.

But I ask myself how I was able to mount the samba share in the first place with the credentials in the fstab.
Shouldn't it work in any case without the smbclient package?

Thank you for the pointers.

Last edited by Iriomote (2026-05-28 15:31:43)

Offline

#6 2026-05-28 15:39:20

cryptearth
Member
Registered: 2024-02-03
Posts: 2,162

Re: [Solved] Mounting samba share with credentials-file failes

because cifs_mount is part of cifs-utils - not smb/samba
while support for a credential file seems to be samba exclusive and hence doesn't work with only cifs

Offline

Board footer

Powered by FluxBB