I logged in to my GCE VM instance (Debian) and installed ufw
and enabled it.
However, I forgot to enable port 22. Is there another way to log in so that I can enable port 22 without having to destroy the instance?
I logged in to my GCE VM instance (Debian) and installed ufw
and enabled it.
However, I forgot to enable port 22. Is there another way to log in so that I can enable port 22 without having to destroy the instance?
No, the only way to access to the instance is through SSH.
You can enable the port 22 using a startup script like the following one:
Then, you can add this startup script to your instance either using the Developers Console and pasting the code in the custom metadata section or using the cloud SDK with the command:
This script will be executed as root every time the instance boots up or reboots so you'll need to restart your instance and you can remove the script once you have achieved your goal with:
You have more information about startup scripts in the documentation.