ArmandduPlessis
ArmandduPlessis

Reputation: 939

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.

Upvotes: 12

Views: 14565

Answers (4)

Venki K
Venki K

Reputation: 21

Try this

Just in case others need to try the same here is the detail

ctrl-shift-p and choose:
Remote-SSH: kill VS Code Server on Host...
Chose the host name
Selected the platform type (linux)
https://github.com/microsoft/vscode-remote-release/issues/4307#issuecomment-762882247

worked for me.

Upvotes: 2

Fatore
Fatore

Reputation: 684

I solved this by enabling the option Lockfiles in Tmp:

enter image description here

Upvotes: 5

NuoYi
NuoYi

Reputation: 601

i just deleted the whole library and it works, i don't see anything wrong with doing that.

rm -r /path_to_project/.vscode-server/

if i'm wrong feel free to correct me :)

Upvotes: 3

ArmandduPlessis
ArmandduPlessis

Reputation: 939

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

Upvotes: 39

Related Questions