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

标签 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 有一些问题,创建了新实例并再次配置,现在它工作正常。

最佳答案

可能是您在 Apache 安装期间启用了防火墙,并且只允许防火墙中的几个端口。
我关注这个 video并且能够通过 session 管理器与实例连接。
当 ssh 不起作用时通过 session 管理器连接实例的步骤
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。重启您的实例并尝试连接 session 管理器
enter image description here
登录后只需禁用防火墙sudo ufw disable并检查安全组中定义的所有入站规则是否有效

关于apache - 安装 apache2 后连接到 ec2 时 SSH 连接超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54586497/

相关文章:

amazon-web-services - AWS : The CIDR '10.30.1.0/24' conflicts with another subnet

ubuntu - 使用 venv 在 WSL 中安装 Python 要求时出现问题

linux - 在ubuntu上安装node-sspi时出现错误

Django:应用程序标签不是唯一的,重复的:bootstrap3

用于将两个(证书和证书 key )文件作为多部分表单数据发送的 HTTP post 请求的 Java 代码

apache - .htaccess - 强制使用单域和 SSL

php - .htaccess 表示 PDF URL

python - Django populate() 不可重入

amazon-web-services - 使用CloudFormation创建本地二级索引

php - Amazon Product API 检索所有产品