Centos – Ask for password while mounting cifs share

centoscifscommand linemount

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)

Best Answer

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.

Related Question