Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS code can't ssh to server: failed to create hard link

SETUP I have a windows 10 PC connecting to my linux server (ubuntu 18.04.2). I run/edit code on my powerful server by remotely accessing the server through VS code's ssh ability. It is super convenient to edit my code on the server with VS code...

THE ISSUE

Visual Studio code won't connect to my Linux server. What is weird is that I am able to ssh into the server from the terminal within VScode by just literally typing ssh <username>@<server-hostname>

However, when I do the Remote-SSH option within VScode then it does not want to connect to the server...strange...

Here is how I remotely SSH into server with VScode built in functionality (marked with red rectangle). Also part of this screenshot is my config file, which I have triple checked as correct (IP address and .ssh/id_rsa_gpu_1_solarpv_ssh location)

enter image description here

HERE IS THE ERROR OUTPUT

enter image description here

MY ATTEMPTS

  1. I have made sure that the config file is setup correctly and that the IP address is correct.
  2. I have ensured that the server's IP address is also in the 'known_hosts' file located at /Users/.ssh/
  3. I even generated my own private key for SSH connection as advised by the great documentation here: https://code.visualstudio.com/docs/remote/troubleshooting#_quick-start-using-ssh-keys

Still getting the error of failed to create hard link...

With all of my back-end stuff done right, I am absolutely clueless regarding why this is an issue.

like image 649
ArmandduPlessis Avatar asked Mar 26 '20 13:03

ArmandduPlessis


People also ask

Could not establish connection VS Code server failed to start?

Open the command panel (Ctrl+Shift+P for Windows and Cmd+Shift+P for Mac), search for Kill VS Code Server on Host, and locate the affected instance, which will be automatically cleared. Then, establish the connection again.

How add SSH key to VS Code?

Add SSH key to your VMSelect Use existing public key in the dropdown for SSH public key source so that you can use the public key you just generated. Take the public key and paste it into your VM setup, by copying the entire contents of the id_ed25519.pub in the SSH public key.

How does VS Code connect to remote server?

In VS Code, select Remote-SSH: Connect to Host... from the Command Palette (F1, Ctrl+Shift+P) and use the same user@hostname as in step 1. If VS Code cannot automatically detect the type of server you are connecting to, you will be asked to select the type manually.

Could not establish connection to could not resolve hostname VS Code?

Open the command panel on VS code ( Ctrl+Shift+P for Windows and Cmd+Shift+P for Mac). Search for Kill VS Code Server on Host , click it - it will be automatically deleted. Reload VS Code and establish connection again.


1 Answers

After spending literally 9 hours on this issue...here is the answer:

When you launch VScode and remotely access the linux server, the linux server is instructed to download and install a vscode server so that you (on the other side) can remotely connect to the server.

If the server does not have internet just make sure the following setting is ticked

enter image description here

This allows the remote server (without or with internet connection) to get the vscode server running.

To eliminate the "failed to create hard link error" go to the directory mentioned by the error, which in this case on linux server is

  1. navigate to /home/<username>/.vscode-server/bin/0ba0ca.../

  2. then remove/delete the hardlink file and target file which also has the same name as the directory.

  3. Then just attempt to remotely access your server again through vscode and all should be fine

Here is also a discussion regarding the issue...if you still have problems https://github.com/microsoft/vscode-remote-release/issues/2507

like image 187
ArmandduPlessis Avatar answered Oct 04 '22 02:10

ArmandduPlessis