在 PuTTY 中启动 SSH 连接,运行命令,并保持会话处于活动状态 [英] Start SSH connection in PuTTY, run a command, and leave the session active

查看:85
本文介绍了在 PuTTY 中启动 SSH 连接,运行命令,并保持会话处于活动状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我通过 PuTTY SSH 到服务器时,我都想运行一些 shell 命令.我正在连接到由其他人管理的生产网络服务器,我不想在那里存储我自己的脚本.

I want to run a few shell commands every time I SSH to a server via PuTTY. I'm connecting to a production web server managed by someone else, and I don't want to store my own scripts there.

我看到选项 Connection > SSH > Remote Command,但是如果我将初始化命令放在那里,在启动会话后,它会在命令执行后立即关闭.如何运行远程命令,然后保持会话打开以便我可以继续使用它?

I see the option Connection > SSH > Remote Command, but if I put my initialization commands there, after starting the session, it closes immediately after the commands execute. How can I run the Remote Command, and then keep the session open so I can continue using it?

推荐答案

命令一完成,SSH 会话就会关闭(并关闭 PuTTY).默认情况下,命令"是一个 shell.由于您已经覆盖了这个默认的命令",但仍然想运行 shell,因此您必须自己显式地执行 shell:

The SSH session closes (and PuTTY with it) as soon as the command finishes. By default the "command" is a shell. As you have overridden this default "command" and yet you want to run the shell nevertheless, you have to explicitly execute the shell yourself:

my-command ; /bin/bash

另见在服务器.

这篇关于在 PuTTY 中启动 SSH 连接,运行命令,并保持会话处于活动状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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