How to disable UFW ubuntu externally?

6,009

Solution 1

thank you for the help guys,

I found a solution to the problem. I have explained them in the below points..

  • I logged into my console and stopped the current instance
  • Then went to the volumes section and detached my volume that was associated with the present instance.
  • Then launched a new instance.
  • then attached the volume of the previous instance to the new instance
  • then logged into the new instance using ssh.
  • used lsblk command to see that block devices attached to my instance. In my case there was two i.e. the one created along with the new instance and it was the root and the next was my previous instances volume which was still not mounted.
  • then I mounted the previous volume into the instance by using the command sudo mount /dev/xvdf1 /mnt -t ext4 (Here i used xvdf1 because my data was present in that)
  • then went to /mnt/etc/ufw/ufw.conf and changed enabled=yes to enabled=no
  • saved the file and logged out
  • again visited AWS console volume section and detached the previous volume and attached it to the stopped previous instance selecting exact previous instance and path as /dev/sda1
  • went to instances tab and started the old instance.
  • Now logged into the instance and it worked like a gem and all the files were intact.

Solution 2

I have the same problem and found out that these steps work:

  1. Stop your instance

  2. Go to `Instance Settings -> View/Change user Data

  3. Paste this

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
--//
  1. Start your instance

Hope it works for you.

Share:
6,009

Related videos on Youtube

Cheran Prakash
Author by

Cheran Prakash

Updated on September 18, 2022

Comments

  • Cheran Prakash
    Cheran Prakash almost 2 years

    i am using amazon EC2, i enabled UFW in my server and without adding any other rule i logged out. now since there was no rule specified, i am not able to login to ssh and because of it even my website is down. can someone help me in how to disable ufw now?

  • Nick
    Nick over 7 years
    When following this, it is also important to unmount the volume using umount /mnt before attempting to detach the volume.
  • SparkAndShine
    SparkAndShine over 3 years
    For new AWS console, try this: right click on your Stopped instance -> Instance Settings -> Edit User Data.