首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么我通过SSH的远程连接在使用SSM代理连接到VS代码中的AWS Cloud9 EC2实例时不能工作?

为什么我通过SSH的远程连接在使用SSM代理连接到VS代码中的AWS Cloud9 EC2实例时不能工作?
EN

Stack Overflow用户
提问于 2022-11-14 22:58:39
回答 2查看 87关注 0票数 2

我无法从Visual代码获得使用这个ssm-proxy.sh脚本远程连接到AWS Cloud9的连接。我正在跟踪这篇文章关于如何使用AWS Cloud9来驱动我的Visual。我可以通过SSH连接,但在调用代理脚本时不行。

这样做是可行的:

代码语言:javascript
运行
复制
Host test1
  HostName xx.xxx.xxx.xx
  User ec2-user
  IdentityFile ~/.ssh/vscloud9

然而,这并不是:

代码语言:javascript
运行
复制
Host cloud9
  IdentityFile ~/.ssh/vscloud9
  User ec2-user
  HostName i-xxxxxxxxxxxxx
  ProxyCommand sh -c "~/.ssh/ssm-proxy.sh %h %p"

使用AWS,我使用访问密钥和json的秘密和输出配置了默认的名为profile。尽管这是一种糟糕的做法,但访问密钥和秘密是为根用户提供的,因此权限不会导致问题。然后在ssm-proxy.sh中详细说明:

代码语言:javascript
运行
复制
AWS_PROFILE='default'
AWS_REGION='eu-west-2'
MAX_ITERATION=5
SLEEP_DURATION=5

安全组中启用了来自任何地方的SSH。

因为普通SSH使用vscloud9密钥,所以密钥对不是问题所在。我认为问题要么是AWS概要文件,要么是ssm-proxy.sh脚本本身。

我正在使用远程SSH VSCode扩展.

我需要让这件事起作用,所以我想知道是否有人知道为什么这不起作用?

回应Anton在评论中的SSH输出:

代码语言:javascript
运行
复制
OpenSSH_9.0p1, LibreSSL 3.3.6
debug1: Reading configuration data /Users/myname/.ssh/config
debug1: /Users/myname/.ssh/config line 6: Applying options for cloud9
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Executing proxy command: exec sh -c "~/.ssh/ssm-proxy.sh i-xxxxxxxxxxxxxx 22"
debug1: identity file /Users/myname/.ssh/vscloud9 type 0
debug1: identity file /Users/myname/.ssh/vscloud9-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.0
debug1: kex_exchange_identification: banner line 0: {
debug1: kex_exchange_identification: banner line 1:     "StartingInstances": [
debug1: kex_exchange_identification: banner line 2:         {
debug1: kex_exchange_identification: banner line 3:             "CurrentState": {
debug1: kex_exchange_identification: banner line 4:                 "Code": 0,
debug1: kex_exchange_identification: banner line 5:                 "Name": "pending"
debug1: kex_exchange_identification: banner line 6:             },
debug1: kex_exchange_identification: banner line 7:             "InstanceId": "i-xxxxxxxxxxxxxx",
debug1: kex_exchange_identification: banner line 8:             "PreviousState": {
debug1: kex_exchange_identification: banner line 9:                 "Code": 80,
debug1: kex_exchange_identification: banner line 10:                 "Name": "stopped"
debug1: kex_exchange_identification: banner line 11:             }
debug1: kex_exchange_identification: banner line 12:         }
debug1: kex_exchange_identification: banner line 13:     ]
debug1: kex_exchange_identification: banner line 14: }
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
EN

回答 2

Stack Overflow用户

发布于 2022-11-29 13:11:03

请检查您的用户名。如果您正在使用ubuntu实例,请尝试在用户名中使用"ubuntu“而不是"ec2-user",反之亦然。

检查你的保安小组。确保您有允许通信从实例返回的出站规则。

使用默认出站规则

代码语言:javascript
运行
复制
type: All traffic, Protocol: All, Ports: All, Destination: 0.0.0.0/0

在我的例子中,用户名是不正确的。在ubuntu实例上,它应该是"ubuntu“,而在amazon实例上,它应该是"ec2-user”。

看起来不错。

票数 0
EN

Stack Overflow用户

发布于 2022-11-29 13:13:36

尝试:

代码语言:javascript
运行
复制
Host cloud9
  HostName xx.xxx.xxx.xx
  User ec2-user
  IdentityFile ~/.ssh/vscloud9
  ProxyCommand sh -c "~/.ssh/ssm-proxy.sh %h %p"

这会重新安排订单,所以我试着看看它是否会按照您提供的顺序工作。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74438823

复制
相关文章

相似问题

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