禁用后在ec2服务器上启用防火墙端口22 [英] enable firewall port 22 on ec2 server after disable it

查看:216
本文介绍了禁用后在ec2服务器上启用防火墙端口22的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

步骤错误:
1. sudo ufw enable
2.命令可能会破坏现有的ssh连接。进行运算(y | n)? y
3.退出
再次执行ssh之前,无法访问。
在安全组上,端口22正在打开
,但是防火墙禁用了端口22。
如何再次访问服务器?

Step error: 1. sudo ufw enable 2. Command may disrupt existing ssh connections. Proceed with operation (y|n)? y 3. exit Before ssh again and can not access. On Security Group, port 22 is opening But firewall disable port 22. How to access server again?

推荐答案

您可以使用以下最简单方法(用户数据)关闭ufw。

You could use the following simplest way (user-data) to turn off the ufw.


  1. 停止实例

  2. 实例设置查看/更改用户数据

  3. 将以下用户数据设置为纯文本并保存

  1. Stop the instance
  2. In Instance Settings, View/Change User Data
  3. Set the below user data as plain text and save



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
--//




  1. 启动实例

由于禁用了ufw,您现在可以通过SSH进入服务器。您可能要停止实例并删除用户数据,然后重新启动。

You will be able to SSH into your server now as ufw is disabled. You might want to stop the instance and remove user data and start it again.

这篇关于禁用后在ec2服务器上启用防火墙端口22的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆