- Newest
- Most votes
- Most comments
Hello.
Please try restoring your instance by following the steps in "An OS-level firewall is blocking SSH port access" in the following document.
Create a snapshot from your existing Lightsail instance, and when restoring from that snapshot, configure a launch script to disable ufw.
https://repost.aws/knowledge-center/lightsail-resolve-ssh-console-errors
sudo ufw disable
sudo iptables -F
sudo mv /etc/hosts.deny /etc/hosts.deny_backup
sudo touch /etc/hosts.deny
sudo systemctl enable sshd
sudo systemctl restart sshd
Step 1: Create a temporary recovery instance Go to Lightsail Console. Launch a new instance with the same OS as your original one (Ubuntu). Wait for it to be ready, then SSH into this temporary instance via web or PuTTY.
Step 2: Attach your original disk to the recovery instance In the Lightsail dashboard, stop the original instance (the one you're locked out of). Go to Snapshots > Create Snapshot of the original instance’s disk (optional but good for safety). Go to the Networking tab, click Create a new disk from this instance (or go to Storage). Attach the disk to the recovery instance you created earlier.
Step 3: Mount the attached disk and fix UFW SSH into the recovery instance. run --> lsblk Identify the attached volume (e.g., /dev/xvdf1) Mount it: sudo mkdir /mnt/recovery sudo mount /dev/xvdf1 /mnt/recovery Disable UFW for the original system: sudo chroot /mnt/recovery ufw disable exit Unmount the disk: sudo umount /mnt/recovery
Step 4: Detach the disk and reattach to original instance Stop the recovery instance. Detach the volume from it. Reattach the volume back to the original instance (if it was a root disk) or simply restart the original instance if the disk was never detached. Start the original instance again.
Step 5: Try SSH again Use the web SSH console or your .pem key from a terminal.
answered a year ago
The steps mentioned above are inapplicable and invalid for Lightsail.

After you restore the instance, you can also use Lightsail's firewall rules to configure your instance: https://docs.aws.amazon.com/en_us/lightsail/latest/userguide/understanding-firewall-and-port-mappings-in-amazon-lightsail.html