-2

I have created a compute engine instance (Debian) in GCP with a public and private key and able to SSH it from my local mac using the command given below.

I have some folders and files in the remote machine which I would like to edit through VS-code (Version: 1.56.1) installed in my local. But when I try to connect it through VS code as per the instructions in manual using this command

ssh -i ~/.ssh/<filename> username@ipaddress

enter image description here

I am getting the below error:

enter image description here

What can I try to fix it?

halfer
  • 19,824
  • 17
  • 99
  • 186
user1403505
  • 895
  • 2
  • 19
  • 42
  • Try increasing the [timeout value](https://stackoverflow.com/questions/59978826/why-ssh-connection-timed-out-in-vscode), set the parameter useLocalServer to false (remote.SSH.useLocalServer": false) under VScode settings and then follow [Connect to remote](https://code.visualstudio.com/docs/remote/ssh#_connect-to-a-remote-host). – Jyothi Kiranmayi Sep 13 '21 at 11:44

1 Answers1

0

It looks to be a specific error from VScode and Remote SSH extension. In some cases it worked when the time out value was increased and when the parameter useLocalServer was set to false (remote.SSH.useLocalServer": false) under VScode settings. Also try upgrading the version for VSCode and see if the issue mitigates.

To edit folders and files in the remote machine through VS-code you can Connect to a remote host.

Steps to connect to a remote host:

  1. Verify you can connect to the SSH host by running the following command from a terminal.

    ssh user@hostname
    
  2. In VS Code, select Remote-SSH: Connect to Host, from the Command Palette and use the same user@hostname as in step 1.

  3. If VS Code cannot automatically detect the type of server you are connecting to, you will be asked to select the type manually.

  4. After a moment, VS Code will connect to the SSH server and set itself up. VS Code will keep you up-to-date using a progress notification and you can see a detailed log in the Remote - SSH output channel.

  5. After you are connected, you'll be in an empty window. You can always refer to the Status bar to see which host you are connected to.

  6. You can then open any folder on the remote machine using File > Open. From here, install any extensions you want to use when connected to the host and start editing.

Refer Connect to remote host for information.

Jyothi Kiranmayi
  • 2,090
  • 5
  • 14