I would like non-root users to be able to mount certain drives on the local network (or have them be mounted automatically on log-in). To mount network drives (via cifs) a password is passed on over the local network to authenticate. I do not want to allow non-root users to see this password. This creates a dilemma: I do not want to store the password in the /etc/fstab file as then non-root users are able to read it. But I need to give users read privileges to the fstab file to allow users to mount the drives.

What would be a secure and sufficiently elegant way (for the user) to go about this?

  • Have you considered using sudo or would you prefer this to work without sudo?
    – Edward
    Jul 18, 2019 at 12:37
  • @Edward Could you elaborate? I would prefer not to have to give users root access.
    – Bib-lost
    Jul 18, 2019 at 13:00
  • 2
    Sure. You could add mount permissions to the sudoers file for specific users, using the credentials file trick ajgringo619 mentions below. That way, they can mount without discovering the actual passwords.
    – Edward
    Jul 19, 2019 at 13:45

1 Answer 1


You can store the username/password for CIFS mounts in a separate file, then reference it in /etc/fstab. Use the credentials=/path/to/your_password_file mount option, then create that file like this:


Save and set the permissions to 600/root:root

  • If I do this, users cannot mount drives which require this username and password. (error 13, permission denied opening credentials file)
    – Bib-lost
    Jul 19, 2019 at 9:21
  • You need to give them (restricted) sudo mount rights, see the comment by Edward on the original question. Jan 13, 2021 at 17:30

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.