挂载 cifs 共享时询问密码

the*_*btm 4 command-line centos mount cifs

我正在寻找一种方法来让 mount 命令提示输入密码,这样我的密码就不会出现在任何系统历史记录中,我以为我会让它read -s -p在 mount 命令内运行命令,但我没有任何运气. 我想知道我的陈述是否错误以及如何错误。

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)
Run Code Online (Sandbox Code Playgroud)

thr*_*rig 5

快速浏览手册页显示:

   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.
Run Code Online (Sandbox Code Playgroud)

因此,不要指定它,或者设置 PASSWD 环境变量。


小智 5

要强制 Centos 提示您输入密码,请安装以下软件包:

samba-client
cifs-utils
Run Code Online (Sandbox Code Playgroud)

您可以通过以 root 身份运行yum install samba-client cifs-utils或使用sudo.

  • 这实际上是标题中描述的问题的有效解决方案。在Ubuntu下,安装了“mounts.cifs”,但它无法挂载共享并出现奇怪的错误(例如挂载是只读的,未指定用户名等),并且在应该提示输入密码时也不会提示输入密码。安装“cifs-utils”以某种方式解决了这个问题。 (4认同)
  • OP 必须已经拥有这些软件包,否则“mount”命令将根本无法工作。 (2认同)