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?

  • I have never used EC2, but it sounds like you have set up a firewall with no allow rules, so there will be no way to connect to it. Disabling the rules will likely require logging in through a terminal emulator. – Paul Nov 16 '15 at 19:52
  • 1
    By terminal emulator I mean something that connects to the terminal of the machine. I know Rackspace offers this for their Public Cloud Servers, but I don't know if Amazon has something similar. It would likely be somewhere in the control panel. – Paul Nov 16 '15 at 20:03
  • 1
    As I suggested in your previous question, you are going to have to somehow access the server through its terminal. If Amazon does not offer an emulator, then you will have to restore from backup. – Paul Nov 16 '15 at 21:48
  • 1
    @CheranPrakash: I also do not use Amazon EC2, but the following answer from Jamieson Becker to a somewhat similar problem may help you: serverfault.com/a/643110/21832 (taken from serverfault.com/questions/144988/root-locked-out-of-ec2) – ricmarques Nov 17 '15 at 0:08
  • 1
    No, there is no bidirectional virtual console tty in EC2. (You can read the output from the virtual console port but that's all.) If you isolate yourself, you are isolated. You will have to repair the server essentially the same way would repair physical server that you had rendered unusable ... stop, detach, attach, mount, repair, unmount, detach, attach, restart ... or, discard the instance and start over. – Michael - sqlbot Nov 17 '15 at 3:53

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.
  • 1
    When following this, it is also important to unmount the volume using umount /mnt before attempting to detach the volume. – Nick Feb 6 '17 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.