apache2安装后,连接到ec2时SSH连接超时

时间:2019-02-08 05:30:10

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

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

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

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

SSH Connection error

这是安全组入站规则

Security group inbound rules

然后在实例日志中检查该内容位于底部

[[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出现了一些问题,创建了新实例并重新配置,现在一切正常。

1 个答案:

答案 0 :(得分:0)

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

我遵循此 video 并且能够通过会话管理器连接到实例。 ssh 不工作时通过会话管理器连接实例的步骤

A.创建角色并分配策略

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

enter image description here

2.附加政策

enter image description here

3.标签跳过

4.审核:添加角色名称 enter image description here


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

登录后只需禁用防火墙 sudo ufw disable 并检查安全组中定义的所有入站规则都应该有效