是否可以在腻子中使用远程命令选项运行多个命令? [英] Is it possible to run multiple command with remote command option in putty?

查看:85
本文介绍了是否可以在腻子中使用远程命令选项运行多个命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在服务器登录时自动运行多个命令,例如sudo bash,ssh server01,ls,cd/tmp等. 我正在腻子中的SSH下使用远程命令选项.

I want to run multiple commands automatically like sudo bash, ssh server01, ls , cd /tmp etc at server login.. I am using Remote command option under SSH in putty.

我用定界符&&尝试了多个命令但不起作用.

I tried multiple commands with delimiter && but not working.

推荐答案

您的问题中缺少一些信息.

There is a some information lacking in your question.

您说要先运行sudo bash,然后再运行ssh server01.

You say you want to run sudo bash, then ssh server01.

sudo会提示您在远程服务器中输入密码吗?

Will sudo prompt for a password in your remote server?

假设sudo中没有密码,运行bash将打开另一个shell,等待用户输入.在退出该bash shell之前,将不运行命令ssh server01.

Assuming there is no password in sudo, running bash will open another shell waiting for user input. The command ssh server01 will not be run until that bash shell is exited.

如果要运行2条命令,请尝试使用以下较简单的命令:

If you want to run 2 commands, try first simpler ones like:

ls -l /tmp ; echo "hi there"

或者,如果您愿意:

ls -l /tmp && echo "hi there"

这行吗?

如果要在运行bash之后运行ssh,则可以尝试:

If what you want is to run ssh after running bash, you can try :

sudo bash -c "ssh server01"

这篇关于是否可以在腻子中使用远程命令选项运行多个命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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