我有一个脚本,使用sudo通过SSH在远程服务器上运行另一个脚本。但是,当我键入密码时,它会显示在终端上。(否则它可以正常工作)
ssh user@server "sudo script"
要想通过SSH输入sudo的密码而不会在输入时出现密码,正确的方法是什么?
发布于 2012-04-25 17:18:26
另一种方法是对ssh
使用-t
开关
ssh -t user@server "sudo script"
请参阅man ssh
-t Force pseudo-tty allocation. This can be used to execute arbi-
trary screen-based programs on a remote machine, which can be
very useful, e.g., when implementing menu services. Multiple -t
options force tty allocation, even if ssh has no local tty.
发布于 2016-12-01 23:20:09
最好的方法是ssh -t user@server "sudo <scriptname>"
,例如ssh -t user@server "sudo reboot"
。它将首先提示用户输入密码,然后再提示root (因为我们是以root权限运行脚本或命令。
我希望它能帮助你消除你的疑虑。
发布于 2012-04-25 14:25:41
目标计算机上的配置中的NOPASS
就是解决方案。继续在http://maestric.com/doc/unix/ubuntu_sudo_without_password上阅读
https://stackoverflow.com/questions/10310299
复制相似问题