6

I am looking for a way to make the mount command prompt for the password so my password doesn't show up in any system history, I thought I would have it run read -s -p command inside of the mount command but I am not having any luck with it. I am wondering if my statement is wrong and how.

mount -t cifs -o domain=domain.ad,user=thebtm,pass=$(read -s -p "password: ") "//NAS/thebtm$/" /mnt/cifsmount
password: mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

2 Answers 2

9

A quick look at the manual page shows:

   password=arg
       specifies the CIFS password. If this option is not given then the
       environment variable PASSWD is used. If the password is not
       specified directly or indirectly via an argument to mount,
       mount.cifs will prompt for a password, unless the guest option is
       specified.

So, leave it unspecified, or set the PASSWD env var.

1
  • on Ubuntu it doesn't prompt me. Complained that it can't mount read-only. This approach is for prompting for a username but it worked for me for prompting for the password. It's visible in the terminal though. askubuntu.com/questions/1067438/… Sep 15, 2023 at 13:41
5

To force Centos to prompt you for a password install the following packages:

samba-client
cifs-utils

You can install these by running yum install samba-client cifs-utils as root or with sudo.

4
  • 2
    The OP must already have these packages because otherwise the mount command wouldn't be working at all. Jan 24, 2017 at 22:31
  • Those are already installed.
    – thebtm
    Jan 25, 2017 at 16:11
  • 4
    This is actually a valid solution for the problem as described in the title. Under Ubuntu, mounts.cifs is installed but it fails to mount shares with weird errors (e.g. mount is read only, username not specified, etc.) and it won't prompt for the password when it should. Installing cifs-utils somehow fixes the problem.
    – Malvineous
    Oct 25, 2018 at 5:34
  • 1
    I had exactly that problem and installing these packages exactly fixed it. It was just not asking for a password and printed an error into the messages. Thumbs Up!
    – Chris
    Mar 19, 2019 at 8:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .