如何在使用AWS SSM获得当前实例访问权限后,对另一个实例进行SSH连接?

huangapple go评论113阅读模式
英文:

How to do a SSH to another instance, after getting access to current instance using AWS SSM?

问题

我正在使用AWS,并且我们已经设置了一个EC2实例,可以使用AWS Session Manager。我能够访问这个系统,但是我想从这里访问其他私有EC2实例。

主机A(通过SSM登录) ----> 主机B

(在这些实例中,像主机B这样的许多其他实例当前没有设置SSM。)

从这里,我尝试:

ssh ec2-user@主机B

但这会失败,因为它需要一个PEM文件。

我在本地机器上有访问此文件的权限,但不知道如何将该文件发送到主机A,以便我可以使用它来SSH登录主机B。

英文:

I am using AWS and we have a EC2 set up, which we can use AWS Session Manager with. I am able to gain access to this system, but from here I want to access other private EC2 instances.

Host A (Logged in via SSM)  ----> Host B

(In these instances, many others like Host B don't have SSM set up right now.)

From here I try, to

ssh ec2-user@HostB

but this fails cause, it requires a PEM file.

I have access to this file on my local machine, but can't figure out how to send that file to Host A so I can use it to SSH into Host B

答案1

得分: 1

将PEM文件的内容简单地复制到剪贴板。然后,使用SSM连接到另一个实例并将其保存到文件中。

您可以运行编辑器(例如vi),或者只需使用cat > key.pem,然后粘贴您的剪贴板内容并输入Ctrl-D

您还需要运行chmod 600 key.pem

要连接,请使用:

ssh -i key.pem ec2-user@HostB

另一种方法是将文件复制到S3,然后从S3下载它。

英文:

Simply copy the contents of the PEM file to your clipboard. Then, use SSM to connect to the other instance and save it to a file.

You can run an editor (eg vi), or just use cat >key.pem then paste your clipboard and type Ctrl-D.

You'll also need to chmod 600 key.pem.

To connect, use:

ssh -i key.pem ec2-user@HostB

Another method is to copy the file to S3 and then download it from S3.

huangapple
  • 本文由 发表于 2023年7月11日 02:59:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76656591.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定