我不断收到此错误,并尝试了多种在线讨论的方法来解决此问题,但没有一种对我有用。我已经安装SSH密钥,所以当我运行'ssh newton@host.com'
它自动记录我,我也设置这个用户visudo
是'newton ALL=(ALL:ALL) ALL'
后来我也尝试添加'newton ALL=NOPASSWD: /var/www/script.sh'
不幸的是,每次我ssh newton@host.com 'sudo /var/www/script.sh'
从 Cygwin运行时,我都会回来。我也尝试添加,-t -t
但它提示我输入密码。
total size is 21209180 speedup is 314.69
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: 3 incorrect password attempts
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: no tty present and no askpass program specified
Sorry, try again.
sudo: 3 incorrect password attempts
Run Code Online (Sandbox Code Playgroud)
Gil*_*il' 12
您需要有一个可以运行的终端,sudo
以便它可以提示您输入密码。如果您将命令传递给ssh
,则它假定该命令不需要终端并且不会创建终端,除非您通过-t
. 有关更详细的说明,请参阅SSH inside SSH failed with "stdin: is not a tty"。
如果您即使使用 也无法输入密码-t
,则您的问题可能是由 Windows 引起的。Windows 控制台不能完全模拟 unix 终端;在这些情况下,Cygwin 应用程序可能难以正确模拟终端(我不确定,请注意)。如果这是问题所在,请ssh
在诸如Console2或 Mintty(包含在 Cygwin 发行版中)之类的终端模拟器中运行— 请参阅在 Windows 7 中使用带有 Cygwin 的 shell 的最佳方法。
如果您希望 SSH 密码替换您的 sudo 身份验证密码,那将不会发生。Sudo 需要密码(除非您NOPASSWD
在 sudoers 文件中添加标签)。请注意NOPASSWD
,如果requiretty
在 sudoers 文件中设置了该选项,则您仍然需要一个终端,即使使用。
如果您希望无密码登录到 root 帐户(从安全角度来看,这通常不是一个好主意),请使用 SSH 访问 root 帐户,最好是两跳。请参阅SSH 内部的 SSH 失败,并显示“stdin: is not a tty”(带有root@host.com
for otheruser@computertwo.com
)。