【问题标题】:SSH connection timed out while connecting to ec2 after apache2 installation安装 apache2 后连接到 ec2 时 SSH 连接超时
【发布时间】:2021-05-13 17:59:42
【问题描述】:

我使用 ubuntu AMI 在 AWS 中创建了一个 ec2 实例,并通过设置 elsatic IP、安全组、Route 53 完成了连接到域的所有必要操作。然后我获得了 PEM 文件并使用私钥连接到 SSH。

在我安装 apache2 并重新启动 apache 服务器之前一切正常。

然后显示连接到端口 22 (SSH) 超时

这里是安全组入站规则

然后检查实例日志在底部得到了这个东西

[[0;32m  OK  [0m] Started The Apache HTTP Server.
[[0;32m  OK  [0m] Started Dispatcher daemon for systemd-networkd.
[[0;32m  OK  [0m] Started Snappy daemon.
         Starting Wait until snapd is fully seeded...
[[0;32m  OK  [0m] Started Wait until snapd is fully seeded.
[[0;32m  OK  [0m] Reached target Multi-User System.
[[0;32m  OK  [0m] Reached target Graphical Interface.
         Starting Update UTMP about System Runlevel Changes...
         Starting Apply the settings specified in cloud-config...
[[0;32m  OK  [0m] Started Update UTMP about System Runlevel Changes.
[   13.456104] cloud-init[1033]: Cloud-init v. 18.3-9-g2e62cb8a-0ubuntu1~18.04.2 running 'modules:config' at Wed, 06 Feb 2019 12:07:07 +0000. Up 13.29 seconds.
[[0;32m  OK  [0m] Started Apply the settings specified in cloud-config.
         Starting Execute cloud user/final scripts...
[   14.093385] cloud-init[1060]: Cloud-init v. 18.3-9-g2e62cb8a-0ubuntu1~18.04.2 running 'modules:final' at Wed, 06 Feb 2019 12:07:08 +0000. Up 13.95 seconds.
[   14.108125] cloud-init[1060]: Cloud-init v. 18.3-9-g2e62cb8a-0ubuntu1~18.04.2 finished at Wed, 06 Feb 2019 12:07:08 +0000. Datasource DataSourceEc2Local.  Up 14.08 seconds
[[0;32m  OK  [0m] Started Execute cloud user/final scripts.
[[0;32m  OK  [0m] Reached target Cloud-init target.

编辑:

AMI 有一些问题,创建了新实例并重新配置,现在一切正常。

【问题讨论】:

  • 重启您的实例并重试。

标签: apache amazon-web-services ubuntu amazon-ec2


【解决方案1】:

可能是您在 Apache 安装期间启用了防火墙,并且只允许防火墙中的几个端口。

我关注了这个video 并且能够通过会话管理器连接到实例。 当 ssh 不工作时通过会话管理器连接实例的步骤

A.创建角色并分配策略

1.选择实体类型 AWS 和用例 ec2

2。附加政策

3.标签跳过

4.审核:添加角色名称


B.将上述角色附加到实例并保存。 c。重启您的实例并尝试连接会话管理器

登录后只需禁用防火墙sudo ufw disable 并检查安全组中定义的所有入站规则是否正常

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-08
    • 2020-03-13
    • 2016-04-15
    • 2014-01-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多