mount.cifs fails (Error 2, no such file or directory) with credentials file, while -o username,password succeeds
A friend helped me figure it out - I was in the directory containing my credentials while running the command, but I needed to provide the absolute path. I'm not sure whether it has to do with the fact that my home directory is in /mnt, but regardless, the following approach succeeds:
$ sudo mount -t cifs -o credentials=/mnt/path/to/mycreds //mydomain/share/Users/me /mnt/mydir
# Success
Related videos on Youtube
John D
Updated on September 18, 2022Comments
-
John D over 1 year
Long time, first time. I'm running RHEL 7.2 (Maipo), and unable to mount a NAS using credentials stored in a file. The directory mounts successfully if I pass username and password directly in the command line, but I'd like to use a credentials file instead for security reasons
$ sudo mount -t cifs -o username=myname,password=mypassword //mydomain/share/Users/me /mnt/mydir # Success $ printf "username=myname\npassword=mypassword\n" >> mycreds $ sudo mount -t cifs -o credentials=mycreds //mydomain/share/Users/me /mnt/mydir # error 2 (No such file or directory) opening credential file mycreds
The password only contains alphanumeric characters, so it's not an issue with special characters.
Permissions on the credentials file are currently set as follows. I started out as the file owner, but that didn't work either.
$ ls -l mycreds # -rwSr-xr-x. 1 root root 40 Mar 19 18:23 mycreds
mount.cifs --version
returnsmount.cifs version: 6.2
I haven't added any lines to /etc/fstab while testing
mount
. I'd like to verify it works from command line first.Let me know if more information would help!
-
roaima about 6 yearsRemove group and other permissions from the credentials file. Otherwise your security is (at best) no better than providing a username and password on the
mount
command line. Usechmod u=rw,go= mycreds
-
roaima about 6 yearsI have always understood that the credentials file required a tuple of { username, password, domain }, where domain is your workgroup.
-