自学内容网 自学内容网

在 EC2 AWS 中开启防火墙后将自己锁定在 SSH 之外

在搭建ftp时,开启了系统防火墙的几个端口,并且设置了防火墙开机自启。当设置好之后,关闭了putty,再次连接SSH时,发现连接错误。仔细一想,防火墙没有开启22端口,这不嘎了么,自己把自己锁门外边了:<

找了一下,还是有方法把防火墙关闭掉的。

1. 在控制台先停止实例

2. 右键点击实例,选择“实例设置”->“编辑用户数据”,如下图所示。

3. 在打开的页面中,选择“将用户数据修改为文本”,也就是下面的内容。然后保存并重启实例就可以了。下面脚本就是禁止防火墙开机自启,并把iptable里的相关规则清空。

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, always]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
ufw disable
iptables -L
iptables -F
--//


原文地址:https://blog.csdn.net/tealcwu/article/details/142827490

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!