AWS EC2 连接在尝试 ssh 进入实例时关闭 [英] AWS EC2 Connection closed by when trying ssh into instance

查看:36
本文介绍了AWS EC2 连接在尝试 ssh 进入实例时关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我设置了一个新的 EC2 实例.第二天我无法通过 ssh 连接到我的实例.我可以在前一天连接和断开连接,我确信我什么也没做.这是 ssh 调试信息:

Recently I set up a new EC2 instance. The next day I was not able to connect to my instance via ssh. I could connect and disconnect the day before, I am sure I did nothing. Here is ssh debug info:

ssh -i webserver.pem -v ubuntu@my.elastic.ip
OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to my.elastic.ip [my.elastic.ip] port 22.
debug1: Connection established.
debug1: identity file webserver.pem type -1
debug1: identity file webserver.pem-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug1: SSH2_MSG_KEXINIT sent
Connection closed by my.elastic.ip

有没有办法解决这个问题?还是我应该重新安装我的实例?

Is there a way to resolve this issue? Or shall I reinstall my instance again?

我的 .pem 的 PS 权限设置为 600.

PS rights to my .pem are set to 600.

推荐答案

检查您的安全组.确保您有一个允许流量从实例返回的出站规则.

Check your security group. Make sure that you have an outbound rule that allows traffic to return from the instance.

使用默认出站规则

type: All traffic, Protocol: All, Ports: All, Destination: 0.0.0.0/0

它会起作用的.

这篇关于AWS EC2 连接在尝试 ssh 进入实例时关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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