Google cloud unable to connect to the VM on port 22
I had the same issue with one of my GCP VM instance. My solution was:
- Shut down the instance
- Click 'Edit' for the instance
- Under 'Custom Metadata' section, add 'startup-script' key, with value:
#! /bin/bash
sudo ufw allow 22
- Click 'Save'
- Start the instance again, and SSH into it
Hope it helps!
General recommendation to troubleshot this issue.
- Make sure the disk resize is done properly. Detailed steps are documented here.
- Confirm the instance has fully booted up. You can confirm this through VM serial console output.
- Once the instance is booted confirm if ssh daemon is running. Serial console output will have information about ssh daemon. If ssh service is not running you can use interactive serial console to start the service.
- Make sure you have firewall rule configured in GCE network to allow ssh port.
- Make sure firewall on the instance(e.g. iptables) is allowing the ssh port. You can use interactive serial console to disable firewall on the VM, if required.