我无法连接到我在 ec2 上的实例。一切都很好,我认为现在ufw有问题。
当我配置我的服务器时,我为 80 端口启用了 ufw,也许它禁用了 22 端口。因为早期一切都很好,但现在我无法通过 ssh 连接。
如何连接到我的 ec2 实例并再次允许 22 端口?
我无法连接到我在 ec2 上的实例。一切都很好,我认为现在ufw有问题。
当我配置我的服务器时,我为 80 端口启用了 ufw,也许它禁用了 22 端口。因为早期一切都很好,但现在我无法通过 ssh 连接。
如何连接到我的 ec2 实例并再次允许 22 端口?
您可以使用以下最简单的方法(用户数据)关闭 ufw,然后访问实例并编辑防火墙。
以下是用户数据:
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
cloud_final_modules:
- [scripts-user, once]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
sudo ufw disable
--//
在此处查看我的答案 在禁用 ec2 服务器后启用防火墙端口 22
您必须检查 EC2 实例下的安全组并在那里启用/添加端口 22。之后,您可以检查端口 80 上的 apache。
如果您不小心阻塞了端口,请使用此链接再次重置它https://u.osu.edu/walujo.1/2017/04/21/how-to-fix-ec2-instance-when-you-accidentally -block-port-22/