location
location

Reputation: 44

Error connecting from VS Code to VM (OS Login, IAP)

I am trying to connect from VS Code on Windows to a Linux VM on Google Cloud.

I can ssh to the VM successfully from Google Cloud SDK Shell using gcloud compute ssh vm tunnel-through-iap. However, when I try using using gcloud compute start-iap-tunnel, the connection doesn't work. When I check sshd logs on the VM, I see:

error: kex_exchange_identification: Connection closed by remote host
Connection closed by 35.235.244.xx port xxxxx

The problem occurs also when I set up the VM as a host in the config file in VS Code and try to connect. If I use ProxyCommand cmd /c "gcloud compute start-iap-tunnel etc..." I hit sshd on the VM, but it says:

error: kex_exchange_identification: Connection closed by remote host
Connection closed by 35.235.244.xx port xxxxx

Since the user can ssh successfully through the tunnel from the SDK shell, we can rule out permission and firewall issues. I gave the user Compute Admin permissions anyway just to rule out such problems while I troubleshoot this connection issue.

Any idea how I can get it to work? Thank you.

Upvotes: -1

Views: 129

Answers (1)

Imran Premnawaz
Imran Premnawaz

Reputation: 265

This error typically indicates an issue with the SSH handshake and also this could happen if the SSH server on the VM is blocked or misconfigured.

Additionally I would recommend you to reset the daemon with: service sshd restart and also try to restart the VS code and check if it is working.Please refer to this for more information on this.

Upvotes: 0

Related Questions