当我阅读 sudo 配置文件时,有一行Defaults visiblepw
.我在手册页中阅读了visiblepw的定义
visiblepw By default, sudo will refuse to run if the user must
enter a password but it is not possible to disable echo
on the terminal. If the visiblepw flag is set, sudo
will prompt for a password even when it would be visi-
ble on the screen. This makes it possible to run
things like “ssh somehost sudo ls since by default,
ssh(1) does not allocate a tty when running a command.
This flag is off by default.
很难理解,谁能解释一下 sudoers 文件中的visiblepw。
答案1
嗯,您知道,如果您调用 sudo 并且它要求您输入密码,您在输入时将看不到它。 sudo 通过禁用 echo 来实现此目的,这意味着它会禁用 shell 功能在屏幕上写入,直到您完成密码写入。
现在,在某些情况下 sudo 无法禁用 echo,联机帮助页中给出了一个示例。默认情况下,如果是这种情况,sudo 会抛出错误,并且不允许您输入密码,因为有人可能会监视您。使用visiblepw你可以禁用这个行为,尽管我不推荐它。