【问题标题】:Unable to connect to AWS instance on port 22无法连接到端口 22 上的 AWS 实例
【发布时间】:2022-01-21 21:26:50
【问题描述】:

直到今天,我们都能够使用连接详细信息通过 ssh 连接到 EC2 实例;当它停止工作并出现以下错误时:

root@DKERP:~# ssh -i "gindustries.pem" ubuntu@ec2-15-184-231-34.me-south-1.compute.amazonaws.com

ssh: connect to host ec2-15-184-231-34.me-south-1.compute.amazonaws.com port 22: Connection timed out

另外,到公共 IP 和端口 22 的 telnet 不起作用

root@DKERP:~# telnet 15.184.231.34  22
Trying 15.184.231.34...
telnet: Unable to connect to remote host: Connection timed out

会话管理器也无法连接并出现以下错误:

We weren't able to connect to your instance. Common reasons for this include:
SSM Agent isn't installed on the instance. You can install the agent on both Windows instances and Linux instances.
The required IAM instance profile isn't attached to the instance. You can attach a profile using AWS Systems Manager Quick Setup.
Session Manager setup is incomplete. For more information, see Session Manager Prerequisites.

AWS 配置中没有防火墙。

概述: 安全组: 实例: 网络接口: 专有网络: 网络 ACL:

系统日志在这里更新:https://pastebin.com/RhAG5DzP

请提出建议。

【问题讨论】:

  • Web ssh 客户端(轻松连接)也不起作用?
  • 不起作用@Marcin
  • 可能实例冻结了。您是否尝试重新启动它或启动新的?
  • 您是否尝试通过会话管理器登录并检查ufw?我试图在您的实例端口 80 上远程登录,它是“可用的”(也许您应该全部关闭它)所以问题不在于连接性。也许防火墙阻止了端口 22
  • 重启也无济于事

标签: amazon-web-services amazon-ec2 connection timeout telnet


【解决方案1】:

Connection timed out 消息通常表示没有网络连接。

在大多数情况下,这是由于安全组。

检查步骤如下:

  • 在 Amazon EC2 管理控制台中选择实例
  • 转到安全标签
  • 检查入站规则

要允许 SSH 连接,需要有一个规则允许端口 22 (SSH) 和 源设置为您的 IP 地址 或来自整个 Internet (0.0.0.0/0) - 最好只有你的 IP 地址,这样其他人都会被阻止。

从控制台启动 Amazon EC2 实例时,它将默认创建一个名为 launch-wizard 的新安全组。但是,通常最好使用有用的名称和您想要的规则创建您自己的安全组。然后,您可以在未来将该安全组重新用于类似的实例。

【讨论】:

  • 这根本没有任何意义!我很高兴它适用于@Asher,但这不是解决方案。他肯定在连接到实例的launch-wizard-1 SG 中打开了端口。
猜你喜欢
  • 2019-06-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-17
  • 1970-01-01
  • 1970-01-01
  • 2016-09-19
  • 1970-01-01
相关资源
最近更新 更多