0 votes
1 view
in AWS by (11.7k points)

I have an EC2 Instance with Ubuntu. I used sudo ufw enable and after only allow the mongodb port

sudo ufw allow 27017

When the ssh connection broke, I can´t reconnect

1 Answer

0 votes
by (18.6k points)

Try the following steps:

1. Launch a new instance

2. Stop the original instance(Don't terminate)

3. Detach the volume from the original instance

4. Attach it to the new instance

5. SSH into the new instance

6. Use sudo lsblk command to display the attached volumes.

7. use the following command to mount your volume

mkdir mnt

sudo mount /dev/xvdf ./mnt

cd mnt/etc/ufw

Note replace /dev/xvdf with the name o your volume as displayed when you ran lsblk command.

8. Open ufw configuration file

sudo vim ufw.conf

9. press i to edit the file

10. Change ENABLED from YES to NO.

11. Type Ctrl-C and type :wq to save the file.

12. Unmount the volume using the following command:


sudo umount /mnt

13: Detach this volume and attach it back to the original instance

now you should be able to SSH into it.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !