通过 ssh sudo 的正确方法 [英] proper way to sudo over ssh

查看:70
本文介绍了通过 ssh sudo 的正确方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,它使用 sudo 在远程服务器上通过 SSH 运行另一个脚本.但是,当我输入密码时,它会显示在终端上.(否则它工作正常)

I have a script which runs another script via SSH on a remote server using sudo. However, when I type the password, it shows up on the terminal. (Otherwise it works fine)

ssh user@server "sudo script"

执行此操作的正确方法是什么,以便我可以通过 SSH 键入 sudo 的密码,而不会在我键入时出现密码?

What's the proper way to do this so I can type the password for sudo over SSH without the password appearing as I type?

推荐答案

另一种方法是使用 -t 切换到 ssh:

Another way is to use the -t switch to ssh:

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.

这篇关于通过 ssh sudo 的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆