Locked myself out of SSH port Ubuntu AWS server using ufw
Published on
145words
1 min read

Authors
Currently, I locked myself out of my VPS (Amazon EC2) after configuring ufw firewall. Here are what I've done to disable ufw and take back the control of my VPS.
- Stop your problem instance
- Paste this script in
Instance Settings > View/Change User Data
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
--//
- Start your instance and now you should be able to SSH.

