How do I connect VSCode Remote Explorer to a Google Cloud instance

275 views Asked by At

I have created a GCP Linux instance. I am running VSCode in Windows. I have run the following commands in the VSCode Terminal:

gcloud auth login
gcloud config set project ecxxxast-377213
gcloud config set compute/zone us-central1-a

This command pops-up a new Bash window:

gcloud compute ssh --zone "us-central1-a" "instance-1" --project "ecxxxast-377213"

This command runs the Bash in the current VSCode terminal:

ssh instance-1.us-central1-a.ecxxxast-377213 

FAILS: Attempting to use "Remote Explorer" extension using the following config file:

Host instance-1.us-central1-a.ecxxxast-377213
  HostName instance-1.us-central1-a.ecxxxast-377213

enter image description here

This is the log file returned:

[20:39:31.250] Log Level: 2
[20:39:31.272] SSH Resolver called for "ssh-remote+instance-1.us-central1-a.ecxxxast-377213", attempt 1
[20:39:31.274] "remote.SSH.useLocalServer": false
[20:39:31.275] "remote.SSH.showLoginTerminal": true
[20:39:31.275] "remote.SSH.remotePlatform": {"biolinux.biotech.cdc.gov":"linux","aspen.biotech.cdc.gov":"linux"}
[20:39:31.276] "remote.SSH.path": undefined
[20:39:31.276] "remote.SSH.configFile": C:\Users\xxx\source\repos\pass-cloud\gcp\config
[20:39:31.276] "remote.SSH.useFlock": true
[20:39:31.276] "remote.SSH.lockfilesInTmp": false
[20:39:31.277] "remote.SSH.localServerDownload": auto
[20:39:31.277] "remote.SSH.remoteServerListenOnSocket": false
[20:39:31.277] "remote.SSH.showLoginTerminal": true
[20:39:31.277] "remote.SSH.defaultExtensions": []
[20:39:31.277] "remote.SSH.loglevel": 2
[20:39:31.277] "remote.SSH.enableDynamicForwarding": true
[20:39:31.278] "remote.SSH.enableRemoteCommand": false
[20:39:31.278] "remote.SSH.serverPickPortsFromRange": {}
[20:39:31.278] "remote.SSH.serverInstallPath": {}
[20:39:31.285] VS Code version: 1.75.1
[20:39:31.285] Remote-SSH version: [email protected]
[20:39:31.285] win32 x64
[20:39:31.287] SSH Resolver called for host: instance-1.us-central1-a.ecxxxast-377213
[20:39:31.287] Setting up SSH remote "instance-1.us-central1-a.ecxxxast-377213"
[20:39:31.294] Using commit id "441438abd1ac652551dbe4d408dfcec8a499b8bf" and quality "stable" for server
[20:39:31.302] Install and start server if needed
[20:39:39.669] Checking ssh with "ssh -V"
[20:39:39.719] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

[20:39:39.723] Using SSH config file "C:\Users\xxx\source\repos\pass-cloud\gcp\config"
[20:39:39.723] Running script with connection command: ssh -T -D 56974 -F "C:\Users\xxx\source\repos\xxx-cloud\gcp\config" "instance-1.us-central1-a.ecxxxast-377213" bash
[20:39:39.727] Terminal shell path: C:\Windows\System32\cmd.exe
[20:39:40.105] > ]0;C:\Windows\System32\cmd.exe
[20:39:40.106] Got some output, clearing connection timeout
[20:39:40.127] > 
> 
> 
[20:39:40.142] > ssh: Could not resolve hostname instance-1.us-central1-a.ecxxxast-377213: No such host is known. 
> The process tried to write to a nonexistent pipe.
> 
[20:39:41.430] "install" terminal command done
[20:39:41.431] Install terminal quit with output: ssh: Could not resolve hostname instance-1.us-central1-a.ecxxxast-377213: No such host is known. 
[20:39:41.431] Received install output: ssh: Could not resolve hostname instance-1.us-central1-a.ecxxxast-377213: No such host is known. 
[20:39:41.433] Resolver error: Error: Could not resolve hostname
1

There are 1 answers

1
Kranthiveer Dontineni On

Like Puteri said there might be some issues with IP resolution, try to use public IP and check. The other possibilities are that you might have done some misconfiguration while configuring your gcloud project in your vscode application, like selecting some default region. Check your gcloud config using the gcloud sdk and reconfigure your gcloud environment in vscode this time without selecting any region. Hope this will solve you issue.