小编Esk*_*ker的帖子

通过 ssh 在他们的机器上以另一个用户身份运行命令?

作为我正常工作流程的一部分,我 SSH 到另一个用户的机器,将用户切换到他们,运行命令,然后再次退出到我自己的机器:

ssh hostname
sudo su user
runcommand
exit
exit
Run Code Online (Sandbox Code Playgroud)

有没有办法将其缩减为单行命令?例如

ssh --someflags "runcommand"
Run Code Online (Sandbox Code Playgroud)

我试过这个,但提示输入我没有的其他用户的密码:

sudo ssh user@hostnme "runcommand"
Run Code Online (Sandbox Code Playgroud)

linux ssh sudo command-line tcsh

5
推荐指数
1
解决办法
3万
查看次数

标签 统计

command-line ×1

linux ×1

ssh ×1

sudo ×1

tcsh ×1