0

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 returns mount.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!

  • Remove 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. Use chmod u=rw,go= mycreds – roaima Mar 22 '18 at 9:28
  • I have always understood that the credentials file required a tuple of { username, password, domain }, where domain is your workgroup. – roaima Mar 22 '18 at 9:31
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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