Step error: 1. sudo ufw enable 2. Command may disrupt existing ssh connections. Proceed with operation (y|n)? y 3. exit Before ssh again and can not access. On Security Group, port 22 is opening But firewall disable port 22. How to access server again?
You could use the following Simplest way (user-data) to turn off the ufw.
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, once]
--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"
#!/bin/bash
sudo ufw disable
--//
You will be able to SSH into your server now as ufw is disabled. You might want to stop the instance and remove user data and start it again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With