47

I am trying to use vscode remote ssh extension and connect to Linux machine that has access to my files. Vscode install the server on the Linux machine under user home directory where due to company policy I have very limited quota . Is there a way to configure vscode to install sever in other location ?

Gama11
  • 31,714
  • 9
  • 78
  • 100
dvir libhaber
  • 473
  • 1
  • 4
  • 4
  • I have no problem to connect through terminal. But can't connect through VScode remote ssh extension. It always show connection time out. I can see the welcome message in my console. But still can't connect and there is no vscod-server installed in my linux server. – Bagusflyer Jun 02 '23 at 06:35

3 Answers3

52

This has been worked out in the new version of vs-code here here, change the variable remote.SSH.serverInstallPath through settings. Example (from tankahabir's comment)

"remote.SSH.serverInstallPath": {
    "work": "/test/location",
    "home": "/foobar"
}
Fabio Iotti
  • 1,480
  • 1
  • 16
  • 20
  • 19
    To clarify the key is the hostname and the value is the location. For instance: ```"my.remote-domain.com": "/foo/myname" ``` – Manish Feb 25 '22 at 08:23
  • 3
    Note, currently it's important to specify the path without a final forward-slash, so you want "/test/location" and NOT "/test/location/". – benbo Sep 12 '22 at 17:12
  • This should (now) be the accepted answer. Note also that you might need to clear down the "old" .vscode-server directories in HOME if, like me, space in the homedir was the main reason why you needed to do this. – undershock Nov 24 '22 at 12:10
  • 3
    Is there a way to use a wildcard for the hostname so that the same path is used for all hosts? – Nola Mar 23 '23 at 19:43
  • This is not working for me. Setting is applied, checked it, VS Code reloaded. Old folder in home dir removed but it keeps recreating it on each connection...setting is ignored. – Hrvoje Jun 02 '23 at 10:52
33

Unfortunately there is no direct way yet with VSCode to install into a custom directory. You could follow below steps to move or install it manually into a different directory.

If your initial installation is successful

  1. Navigate to a desired project space directory from remote desktop terminal

    $ cd /your/big/disk/project/space

  2. Move vscode-server to this area

    $ mv ~/.vscode-server .

  3. Create symlink of .vscode-server in your home directory. Use absolute paths in this command to avoid cyclic links.

    $ ln -s /your/big/disk/project/space/.vscode-server ~/.vscode-server

  4. Confirm no cyclic links with below command, it should not return anything.

    $ find -L ./ -mindepth 15

  5. Reconnect from your VSCode again. Now when VSCode looks for the remote sever in your home directory, it would be redirected to the different directory seamlessly.

If your initial installation fails (for reasons like cannot extract vscode-server on remote system due to space restriction). I had to make it work this way.

  1. Get vscode-server commit ID on remote server using below command, which would be like 'e2d4cc38bb5da82wb67q86fd50f84h67bb340987'. Replace $COMMIT_ID with your actual commit ID from here on.

    $ ls ~/.vscode-server/bin

  2. Download tarball replacing $COMMIT_ID with the commit number from the previous step on local system. Or, if you have outbound connectivity on remote system, you could directly download it there and skip step 3.

    https://update.code.visualstudio.com/commit:$COMMIT_ID/server-linux-x64/stable

  3. Move tarball to remote server disk from local system. Below command puts it in home dir of remote system.

    $ scp -P 22 vscode-server-linux-x64.tar.gz remoteID.remote.system.url.com:~/

  4. Move tarball to large free space directory as below:

    $ mkdir -p /your/big/disk/project/space/.vscode-server/bin/$COMMIT_ID/

    $ mv ~/vscode-server-linux-x64.tar.gz /your/big/disk/project/space/.vscode-server/bin/$COMMIT_ID/

  5. Extract tarball in this directory

    $ cd /your/big/disk/project/space/.vscode-server/bin/$COMMIT_ID

    $ tar -xvzf vscode-server-linux-x64.tar.gz --strip-components 1

  6. Create symlink of .vscode-server in your home directory. Use absolute paths in this command to avoid cyclic links.

    $ ln -s /your/big/disk/project/space/.vscode-server ~/.vscode-server

  7. Confirm no cyclic links with below command, it should not return anything.

    $ find -L ./ -mindepth 15

  8. Connect again. Now when VSCode looks for the remote sever in your home directory, it would be redirected to the different directory seamlessly.

HoldOffHunger
  • 18,769
  • 10
  • 104
  • 133
sgX
  • 696
  • 1
  • 8
  • 16
0

Adding to @Pranarsh's correct answer (as a different answer because a screenshot is included) -

as of at least Aug2023 there's UI for this. Go to settings (Ctrl+, by default) and type eg "Server Install Path" at the search box:

enter image description here

You can then conveniently Add New server name and vscode-server path to be used for it.

Ofek Shilon
  • 14,734
  • 5
  • 67
  • 101