首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法从本地设置ssh配置远程转发-->堡垒--> EC2

无法从本地设置ssh配置远程转发-->堡垒--> EC2
EN

Stack Overflow用户
提问于 2021-04-21 07:57:19
回答 1查看 152关注 0票数 1

概述

我正在尝试配置~/.ssh/ VSCode以将本地配置连接到远程(EC2)。我做了很多测试,我不明白为什么第一种情况是有效的,而其他情况是失败的。在ssh进入EC2实例之后,我能够让RemoteCommand成功地进入BastionHost实例,但是我无法在ProxyJump或ProxyCommand中实现同样的效果。在使用RemoteCommand示例时,VSCode没有列出EC2文件系统(只列出了BastionHost),因此根据大多数文档,我认为我需要解析为代理跳转/代理命令。

我试着完全按照here的说明进行,同时尝试了其他文章中的不同方法,但都无济于事。

代码语言:javascript
运行
复制
##WORKS
Host dev-ec2
  HostName 10.248.000.206
  User meme1
  RemoteCommand ssh 10.248.000.201
  RequestTTY yes
  IdentityFile ~/.ssh/mykey

##WORKS
Host bastion-dev
  HostName 10.248.000.206
  User meme1
  IdentityFile ~/.ssh/mykey
  RequestTTY yes

##FAILS (times out)
Host dev-ec2-proxycommand
  HostName 10.248.000.201
  User meme1
  ProxyCommand ssh.exe bastion-dev -W %h:%p

##FAILS (Permission denied on public key, even though no issue in the RemoteCommand example)
Host ec2-dev-proxyjump
  HostName 10.248.000.201
  User meme1
  ProxyJump bastion-dev
  IdentityFile ~/.ssh/mykey

系统信息

操作系统: Windows 10 Bastion操作系统: Linux (Amazon Linux AMI)

免责声明

在过去的几天里,我一直在StackOverflow和其他论坛上搜索,但都无济于事,尽管我也发现了类似的问题,但没有一个提供可行的解决方案。

EN

回答 1

Stack Overflow用户

发布于 2021-04-23 02:09:52

我想下面这个是失败的,因为你在你的堡垒里使用了Windows的一个命令,那就是Linux。

命令ssh.exe在Linux上不起作用。你放在ProxyCommand上的所有东西都将在你的堡垒主机中运行,在你的例子中,它是一个Linux操作系统。

此外,请确保您的实例安全组允许从堡垒IP连接,而不是从您的计算机连接。

代码语言:javascript
运行
复制
##FAILS (times out)
Host dev-ec2-proxycommand
  HostName 10.248.000.201
  User meme1
  ProxyCommand ssh.exe bastion-dev -W %h:%p

我的~/.ssh/config文件中有以下配置,它可以很好地连接堡垒主机后面的实例。

堡垒IP:172.31.4.238

主机IP (堡垒后):172.31.11.98

代码语言:javascript
运行
复制
Host 172.31.11.98
  HostName 172.31.11.98
  User ec2-user
  ProxyCommand ssh -W %h:%p ec2-user@172.31.4.238

请看下面的内容

代码语言:javascript
运行
复制
$ ssh 172.31.11.98
The authenticity of host '172.31.11.98 (<no hostip for proxy command>)' can't be established.
ECDSA key fingerprint is SHA256:vy....
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '172.31.11.98' (ECDSA) to the list of known hosts.

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
[ec2-user@ip-172-31-11-98 ~]$
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67187666

复制
相关文章

相似问题

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