Hi guys 😎! It’s been a long time since my last post but, “Better Late Than Never”. So we are talking today about UFW. I have lots of friends who ask me how to disable UFW in AWS Ubuntu as they could not do SSH to the server. So, I decided to come up with this topic.
It’s quite simple to disable UFW in AWS Ubuntu from the AWS console without using SSH.
So basically, UFW stands for Uncomplicated Firewall, a default firewall configuration tool for Ubuntu. UFW provides a user-friendly way to create an IPv4 or IPv6 host-based firewall. By default, UFW is disabled.
So now let’s see how to disable it through the AWS console without using any SSH client.
Here are the steps,
- Login to your AWS console and go to the EC2 page
- Select the EC2 instance, stop the instance
- Right-click the EC2 instance, go Instance settings then Edit user data.
- Paste below code to Modify user data as text then save (you may remove sudo).
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
sudo ufw disable
sudo iptables -L
sudo iptables -F
--//
- Restart your instance
- Verify your public IP address (normally it will be changed after your stop & restart)
- SSH to the EC2 instance with a new IP address.
Thas it. Now you can access SSH using the new IP address. 😎