首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SSH连接在RemoteCommand之后立即关闭

SSH连接在RemoteCommand之后立即关闭
EN

Unix & Linux用户
提问于 2019-06-14 18:23:45
回答 1查看 1.6K关注 0票数 2

我的MacBook上有一个MacBook配置文件,用于连接到远程Ubuntu服务器。配置文件如下所示:

代码语言:javascript
复制
Host remote_computer
    HostName 1.2.3.4
    Port 22
    User remote_username
    IdentityFile ~/.ssh/id_rsa
    RemoteCommand echo "Hello, World!"

下面是我尝试连接时所发生的事情:

代码语言:javascript
复制
local_computer:/ local_username$ ssh remote_computer
Hello, World!
local_computer:/ local_username$ 

RemoteCommand成功运行,但随后连接立即关闭。我尝试的任何RemoteCommand都会发生这种情况,但是如果我从配置文件中删除RemoteCommand,则连接将保持打开状态:

代码语言:javascript
复制
local_computer:/ local_username$ ssh remote_computer
remote_username@remote_computer:~$ 

Why在成功运行配置文件 RemoteCommand from之后是否关闭连接,我能做什么来阻止

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2019-06-14 18:51:41

强制TTY并输入shell:

代码语言:javascript
复制
Host remote_computer
    HostName 1.2.3.4
    Port 22
    User remote_username
    IdentityFile ~/.ssh/id_rsa
    RemoteCommand echo "Hello, World!" && bash
    RequestTTY force
票数 4
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/524969

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档