Error 4003: can't ssh login into the instance that I created in google cloud platform

Viewed 30051

I am using GCP and I created a vm instance, but I can't ssh into the machine. This is the error I am getting:

Connection via Cloud Identity-Aware Proxy Failed Code: 4003 Reason: failed to connect to backend

As I search it is because of This might mean the instance isn't listening on the port you're trying to connect to or the firewall is closed.

Here is my firewall config:

0.0.0.0/0 Deny All

4 Answers

This may not be a complete answer, but at the very least your firewall rules aren't allowing connections on the SSH port. There should be an ingress rule to allow traffic to the instance on TCP port 22 (SSH) on that VPC network.

Generally, this is automatically created by GCP, on the default network it is typically called "default-allow-ssh", but you can also manually create it in the VPC Network -> Firewall rules tab. Make sure it applies to the instance in question (either through "All targets" or a target tag that matches the instance). You can read more about GCP firewall rules in the documentation.

Likewise, make sure you have an external IP or that you are following one of the options described here.

If firewall rules are ok, you may have blocked port 22 (e.g. by using ufw enable command). If so:

  1. Apply a startup script to running instance (instructions for instance that is already running - in the middle of the page)
  2. Key: startup-script Value: ufw allow 22
  3. Stop the instance and start it again

You are done. Use SSH to connect to your instance.

Just Create another instance and use the same the snapshot of the instance that is not working and then the external ip address of the not working instance will bounce to the created instance. It works.

If you want to use the web interface you can use the following instructions to enable ssh button on the web interface and ssh through that.

See instructions to show which permission are needed here

To solve the actual error: Please consider adding the IAP-secured Tunnel User IAM role to start using Cloud IAP for TCP forwarding for better performance.

Solution: Add "IAP-secured Tunnel User" @project level for that user.

Related