Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in AWS by (12.9k 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.2k 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:

cd

sudo umount /mnt

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

now you should be able to SSH into it.

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
asked Jul 10, 2019 in AWS by yuvraj (19.1k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.2k users

Browse Categories

...