在已登录 shell 中使用 ssh 从 windows 和 运行 命令登录到 linux 终端
Using ssh to login to linux terminal from windows and run command in a logged in shell
首先,这似乎是一个重复的问题,但我搜索了 stack overflow/various 其他论坛网站,但仍未找到解决方案。
我查看了一些示例论坛帖子,以证明我在提问之前已经完成了研究:
- https://superuser.com/questions/130443/remotely-run-script-on-unix-get-output-locally
- https://linuxconfig.org/executing-commands-remotely-with-ssh-and-output-redirection
- https://zaiste.net/posts/few-ways-to-execute-commands-remotely-ssh/
- https://unix.stackexchange.com/questions/474533/get-output-of-this-command-from-another-server-via-ssh
- Run ssh and immediately execute command
- https://www.cyberciti.biz/faq/unix-linux-execute-command-using-ssh/
还有数百个,但我不会全部包括在内。
我基本上需要一个 shell 脚本来在 windows 上打开命令提示符,登录到远程 linux 系统和 运行 命令。
我知道这可以通过以下方式完成:
start cmd /k ssh user@host ls
但上面的问题是ssh连接在任务完成后关闭。
我也知道我可以通过添加以下内容来保持 ssh 连接打开:
bash -l
在某些情况下。
对于我的用例,我需要 运行 ROS(机器人操作系统)的启动文件,为此我需要查看命令的输出。
并且在尝试 运行 roslaunch launchFile.launch(代替上面的 ls)时:
start cmd /k ssh user@host "roslaunch launchFile.launch"
命令提示符returns
bash: roslaunch: command not found
我显然已经清理了启动文件的具体名称,但是
roslaunch launchFile.launch
运行 如果我先登录 linux PC 就完美了:
ssh user@host
然后 运行 命令。
我已经在 MacOS 上实现了这个确切的用例,但我现在需要在 windows:
上重新实现相同的解决方案
osascript -e 'tell app "Terminal"
do script "ssh quantum@172.23.199.1 \n
roslaunch launchFile.launch"
end tell'
在此先感谢您的帮助或建议。
试试这个:
start cmd /k ssh user@host "/full/path/to/roslaunch launchFile.launch; exec /bin/bash"
首先,这似乎是一个重复的问题,但我搜索了 stack overflow/various 其他论坛网站,但仍未找到解决方案。
我查看了一些示例论坛帖子,以证明我在提问之前已经完成了研究:
- https://superuser.com/questions/130443/remotely-run-script-on-unix-get-output-locally
- https://linuxconfig.org/executing-commands-remotely-with-ssh-and-output-redirection
- https://zaiste.net/posts/few-ways-to-execute-commands-remotely-ssh/
- https://unix.stackexchange.com/questions/474533/get-output-of-this-command-from-another-server-via-ssh
- Run ssh and immediately execute command
- https://www.cyberciti.biz/faq/unix-linux-execute-command-using-ssh/
还有数百个,但我不会全部包括在内。
我基本上需要一个 shell 脚本来在 windows 上打开命令提示符,登录到远程 linux 系统和 运行 命令。
我知道这可以通过以下方式完成:
start cmd /k ssh user@host ls
但上面的问题是ssh连接在任务完成后关闭。 我也知道我可以通过添加以下内容来保持 ssh 连接打开:
bash -l
在某些情况下。
对于我的用例,我需要 运行 ROS(机器人操作系统)的启动文件,为此我需要查看命令的输出。
并且在尝试 运行 roslaunch launchFile.launch(代替上面的 ls)时:
start cmd /k ssh user@host "roslaunch launchFile.launch"
命令提示符returns
bash: roslaunch: command not found
我显然已经清理了启动文件的具体名称,但是
roslaunch launchFile.launch
运行 如果我先登录 linux PC 就完美了:
ssh user@host
然后 运行 命令。
我已经在 MacOS 上实现了这个确切的用例,但我现在需要在 windows:
上重新实现相同的解决方案osascript -e 'tell app "Terminal"
do script "ssh quantum@172.23.199.1 \n
roslaunch launchFile.launch"
end tell'
在此先感谢您的帮助或建议。
试试这个:
start cmd /k ssh user@host "/full/path/to/roslaunch launchFile.launch; exec /bin/bash"