简体   繁体   English

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

[英]SSH connection timed out while connecting to ec2 after apache2 installation

I created an ec2 instance in AWS with ubuntu AMI and done all necesaary things to connect to the domain by setting up elsatic IP, Security Group, Route 53. Then I got the PEM file and connected to the SSH using private keys.我使用 ubuntu AMI 在 AWS 中创建了一个 ec2 实例,并通过设置弹性 IP、安全组、Route 53 完成了连接域的所有必要操作。然后我获得了 PEM 文件并使用私钥连接到 SSH。

It is all working fine till I installed apache2 and restarted the apache server.一切正常,直到我安装了 apache2 并重新启动了 apache 服务器。

Then after, it is showing connection timed out to port 22 (SSH)然后,它显示连接超时到端口 22 (SSH)

SSH 连接错误

here is the security group inbound rules这是安全组入站规则

安全组入站规则

then checked in instance log got this thing at the bottom然后检查实例日志在底部得到了这个东西

[[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.

EDIT:编辑:

AMI has some issues, created new instance and configured all again now it is working fine. AMI 有一些问题,创建新实例并重新配置所有现在它工作正常。

May be you have enable firewall during Apache installation and allow only few ports in firewall.可能是您在 Apache 安装过程中启用了防火墙并且只允许防火墙中的几个端口。

I follow this video and was able to connect with instance through session manager.我关注了这个视频并且能够通过会话管理器连接到实例。 Steps to connect with instance though session manager when ssh not works当 ssh 不起作用时通过会话管理器连接实例的步骤

A. Create Role and assign policy A. 创建角色并分配策略

1. Choose entity type AWS and use case ec2 1. 选择实体类型 AWS 和用例 ec2

在此处输入图片说明

2. Attach policy 2. 附加政策

在此处输入图片说明

3. tags skip 3.标签跳过

4. Review: Add role name 4.查看:添加角色名称在此处输入图片说明


B. Attach above role with instance and save. B. 将上述角色附加到实例并保存。 在此处输入图片说明 c. C。 Reboot your instance and try to connect with session manager重启您的实例并尝试连接会话管理器在此处输入图片说明

After login just disable firewall sudo ufw disable and check all inbound rule defined in security group should work登录后只需禁用防火墙sudo ufw disable并检查安全组中定义的所有入站规则应该可以工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM