google-cloud-platformsshvirtual-machinegoogle-cloud-compute-engine

Google Compute Engine Unable to Access VM


I am unable to ssh into a VM on GCP Compute Engine

enter image description here

However, when I run the command with the --troubleshoot flag, it seems like everything is okay.

enter image description here

When I connect through the console, I get an error message saying "You cannot connect to the VM instance because of an unexpected error".

Also, other people from my organization are able to connect.

I am unable to figure out what the error is. Any help would be appreciated.


Solution

  • From the error message that you got "Permission denied (publickey)" you can check this documentation for further troubleshooting.

    Further more you can investigate also the Identity-Aware Proxy (IAP). If you use Identity-Aware Proxy (IAP) for TCP forwarding, update your custom firewall rule to accept traffic from IAP, then check your IAM permissions.

    1. Update your custom firewall rule to allow traffic from 35.235.240.0/20, the IP address range that IAP uses for TCP forwarding. For more information, see Create a firewall rule.

    2. Grant permissions to use IAP TCP forwarding, if you haven't already done so.

    For the error message "You cannot connect to the VM instance because of an unexpected error".

    gcloud compute firewall-rules create FIREWALL_NAME \
      --allow tcp:PORT_NUMBER
    

    For further troubleshooting on SSH you see this documentation on Common SSH errors.