56

Is there a way to use the VSCode Remote SSH extension to interact with a remote host that does not allow outbound internet connections?

Is it possible to download the vscode-server files from another system and copy to host?

I read this but I can't connect the server to internet.

auser
  • 6,307
  • 13
  • 41
  • 63
Fakhamatia
  • 1,202
  • 4
  • 13
  • 24
  • Connect to what? Are you trying to install VSCode without an internet connection? Please clarify what you're talking about. – ifconfig Jun 23 '19 at 08:51
  • 2
    @ifconfig sorry for my bad English , i want use ssh remote extension of vscode , the client is connect to internet but server is not connect – Fakhamatia Jun 24 '19 at 14:25
  • 1
    VSCode Remote access works based on the premise that both the client and server machines are connected to the internet. Otherwise, they are unable to communicate. If your client device is on the same network as the server device, then there could be a workaround. – ifconfig Jun 24 '19 at 15:18

5 Answers5

145

When you connect to a host it executes a bash script that wgets or curls a tarball and extracts it in a directory in your home directory. Here's an offline workaround.

  1. Attempt to connect, let it fail

  2. On server, get the commit id

    $ ls ~/.vscode-server/bin
    553cfb2c2205db5f15f3ee8395bbd5cf066d357d
    
  3. Download tarball replacing $COMMIT_ID with the the commit number from the previous step

For Stable Version

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

For Insider Version

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

  1. Move tarball to ~/.vscode-server/bin/$COMMIT_ID/vscode-server-linux-x64.tar.gz

  2. Extract tarball in this directory

    $ cd ~/.vscode-server/bin/$COMMIT_ID
    $ tar -xvzf vscode-server-linux-x64.tar.gz --strip-components 1
    
  3. Connect again

You'll still need to install any extensions manually. There's a download button next to all the extensions in the marketplace. Once you have the .vsix file you can install them through the GUI with the Install from VSIX option in the extensions manager.

This is kind of a pain and hopefully they improve this process, but if you have a network-based home directory, you only have to do this once.

Rahul Kumar
  • 2,184
  • 3
  • 24
  • 46
aviso
  • 2,371
  • 1
  • 14
  • 15
  • 1
    server is armhf not amd64. i change url to server-linux-armhf/stable but show 404 – Fakhamatia Jul 01 '19 at 04:57
  • I don't think they are supporting server on ARM at this point – aviso Jul 02 '19 at 15:24
  • The Nightly support , vscode connect to server but cant download files – Fakhamatia Jul 02 '19 at 20:10
  • 1
    @aviso can you add how you manually install extensions? it's one thing to download the vsix and scp it to the server you need it for but trying to manually install from vsix looks at your local host not the remote. Please provide clarity and I'll upvote. – WSLUser Jul 19 '19 at 18:19
  • 1
    @WSLUser You install them from the client GUI. Just put them in a place you can browse to on the client. In VScode, connect to the remote host, then in the extension manager click on the three dots at the top right, and select **Install from VSIX**. There's a delay while it copies and installs the extension, but then you should see it listed in the extension manager. – aviso Jul 20 '19 at 19:11
  • 2
    I can confirm this method works for remote Docker containers as well. I'm using Windows 10 Hyper-V with Linux Container and was receiving ```Failed to download VS Code Server (https://update.code.visualstudio.com/commit:$COMMIT_ID/server-linux-x64/stable): HTTP 407 - authenticationrequired)```, presumably because of my corporate proxy. Note that if you've made multiple installation attempts like I did, you'll have a folder in ```~/.vscode-server/bin/``` with an appended timestamp for each attempt. Remove all and leave a single folder with just the COMMIT_ID (no timestamp). – danialk Aug 30 '19 at 15:33
  • 3
    Thank you, it worked, even without unpacking .tar file, just drop it there – Alex Dembo Sep 10 '19 at 07:11
  • This method its work, but VSCode bring new option: "remote.SSH.allowLocalServerDownload": true – Fakhamatia Sep 17 '19 at 11:27
  • 1
    What should be the URL, if I want to do it for vscode insiders (instead of stable)? Below vscode-insiders commitid doesn't seem to work "c8d44e24dd250d416475a10efe64e35c9e2c65b3". – Snehasish Sarkar Nov 08 '19 at 06:56
  • 5
    You can replace `commit:` with `latest` to get the latest release build. Example: `https://update.code.visualstudio.com/latest/server-linux-x64/stable`. Respects indicated quality i.e, `stable`, `insider`. Copied my comment [here](https://stackoverflow.com/questions/56671520/how-can-i-install-vscode-server-in-linux-offline#comment113512044_57601121) – Doom5 Oct 04 '20 at 06:47
  • 1
    @Fakhamatia It only works if the client has internet access. This method is still useful when both the client and the host do not have internet access. – D_S_toowhite Aug 25 '21 at 09:31
  • 4
    For the windows server, use `server-win32-x64` instead of `server-linux-x64` – Qwerty01 Sep 08 '21 at 21:40
  • One thing that affacts me is to set a larger time out`ConnectionTimeout:45`, default is 15. – haojie Oct 22 '21 at 08:30
  • Note that the `COMMIT_ID` is also listed under `code --version`, rather than running step 1 & 2 – Maximilian May 14 '22 at 20:37
  • If you want this to work with Remote Containers, you can extract the vscode-server archive locally to a path ending with vscode-server/bin/linux-x64/, then add a mount point in your .devcontainer file as follow: `"source=/vscode-server,target=/vscode/vscode-server,type=bind"` – digitalTrilunaire Sep 06 '22 at 11:11
  • [404 not found] https://update.code.visualstudio.com/commit:6ab598523be7a800d7f3eb4d92d7ab9a66069390/server-linux-x64/insider – CS QGB Dec 15 '22 at 10:25
  • 1
    @CSQGB, it looks like you're using a stable commit ID with the insider URL, change insider to stable at the end of the URL – aviso Dec 16 '22 at 14:24
5

open vscode -> about

Version: 1.46.1

Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d

Date: 2020-06-17T21:17:14.222Z

Electron: 7.3.1

Chrome: 78.0.3904.130

Node.js: 12.8.1

V8: 7.8.279.23-electron.0

OS: Darwin x64 17.7.0

$COMMIT_ID = cd9ea6488829f560dc949a8b2fb789f3cdc05f5d

dfasfs
  • 51
  • 1
  • 1
4

A new feature is being added to support offline install

However, you can now solve this issue by a new user setting in the Remote - SSH extension. If you enable the setting remote.SSH.allowLocalServerDownload, the extension will install the VS Code Server on the client first and then copy it over to the server via SCP.

Note: This is currently an experimental feature but will be turned on by default in the next release

https://code.visualstudio.com/blogs/2019/10/03/remote-ssh-tips-and-tricks

Community
  • 1
  • 1
Jonathan Parker
  • 6,705
  • 3
  • 43
  • 54
  • 5
    This only solves the usecase of where the client has access but the remote host does not. The answer above is still the correct solution. – WSLUser Jan 10 '20 at 16:20
  • 1
    This option has now been replaced with `remote.SSH.allowLocalServerDownload` taking "always", "auto" and "off" as options – user2746401 Feb 18 '21 at 16:34
  • In current Version (1.62.0) this setting was replaced by `remote.SSH.localServerDownload` with values of `off`, `auto` or `always`. – Michael Nov 09 '21 at 09:39
  • not working if a client has no internet connection either. – Ted Dec 12 '22 at 03:10
1

Current Version of VS Code: 1.48.2

I just kill the wget process on the server end, and let the client download the archive and transfer it to the server end. That's quite easy as below.

  1. make sure that you set in settings.json
"remote.SSH.allowLocalServerDownload": true,
  1. execute the shell scrpits below.
# to find the <pid>
ps aux | grep wget | grep vscode-server

# kill the process
kill -9 <pid>

# then wait for the client downloading and transferring

# optional: If you want to know the progress, just 
cd ~/.vscode-server/bin/<commit-id>/
watch -n 1 -d ls -rthl
Jaxx Zhang
  • 19
  • 2
  • 3
    In current Version (1.62.0) this setting was replaced by `remote.SSH.localServerDownload` with values of `off`, `auto` or `always`. – Michael Nov 09 '21 at 09:36
0

A a work around I have done the following:

Desktop ~/.ssh/config

...

Host *
  RemoteForward 54321

...

Remote: ~/bin/wget in which ~/bin is added to PATH via .bashrc

#!/bin/bash
export LD_LIBRARY_PATH=$HOME/opt/lib/tsocks/
export TSOCKS_CONF_FILE=$HOME/opt/tsocks/tsocks.conf
$HOME/bin/tsocks /usr/bin/wget $@

Remote: ~/opt/tsocks/tsocks.conf

server = 127.0.0.1
server_port = 54321
server_type = 5

note tsocks binary has been scp-ed to ~/bin/tsocks and ~/opt/tsocks/ has been created with libtsocks.so which is normally stored in /usr/lib64/libtsocks.so

This is a work around that allows me to have wget functionality with out messing with anything outside my profile to get it to work (eg: no root required ... even though I have it).

CaffeineAddiction
  • 803
  • 1
  • 14
  • 29