运行ssh并立即执行命令 [英] Run ssh and immediately execute command

查看:1038
本文介绍了运行ssh并立即执行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到UNIX或bash命令连接到SSH服务器后运行的命令。例如:

  SSH名@ IPTMUX列表的会话

以上code ++工程,它列出了会议,但随后立即断开连接。把它在服务器端的SSHRC作品,但我需要能够给它的客户端类型。我希望能够运行一个命令,它登录,打开的窗口中,然后运行我的命令集。香港专业教育学院试图

  [命令] | SSH名@ IPSSH名@ IP [命令]SSH名@ IP[命令]SSH -t名@ IP [命令]


解决方案

 的ssh -t命令;庆典-l

将执行该命令,然后当它完成启动一个登录shell。

I'm trying to find UNIX or bash command to run a command after connecting to an ssh server. For example:

ssh name@ip "tmux list-sessions"

The above code works, it lists the sessions, but it then immediately disconnects. Putting it in the sshrc on the server side works, but I need to be able to type it in client side. I want to be able to run a command, it logs in, opens up the window, then runs the command I've set. Ive tried

[command] | ssh name@ip

ssh name@ip [command]

ssh name@ip "[command]"

ssh -t name@ip [command]

解决方案

ssh -t 'command; bash -l'

will execute the command and then start up a login shell when it completes.

这篇关于运行ssh并立即执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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