我有一个脚本,它通过 SSH 在远程服务器上运行另一个脚本sudo
。但是,当我输入密码时,它会显示在终端上。否则它工作正常。
ssh user@server "sudo script"
执行此操作的正确方法是什么,以便我可以输入密码sudo
通过 SSH 在我输入时不显示密码?
另一种方法是使用-t
开放给ssh
:
ssh -t user@server "sudo script"
See man ssh https://linuxcommand.org/lc3_man_pages/ssh1.html:
-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.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)