1. Introduction
Here is a common scenario:
- You have a target linux server without public network access, but you want to connect to it using VSCode Remote SSH.
- Or even further, your target server is running several Docker containers, and you want to attach to the containers on VSCode.
- You also need compatible extensions to be installed, so that you can actually work with your target server or containers.
What a pain! But don’t worry, this article will show several methods to install VSCode Server and extensions offline, which can hopefully save you a lot of time and effort.
2. Method 1: Copy from Another Linux Server
😎 This is the easiest method!
- Connect to another Linux server (or WSL) which has access to the public network with VSCode Remote SSH on your local machine.
- On the server, you would find the
~/.vscode-server
directory, which contains everything you need for SSH connection and all the extensions you have installed. - Copy the
~/.vscode-server
directory to your target server. - If you want to attach to a container on the server, copy the
~/.vscode-remote
directory to the container; For example:1
docker cp ~/.vscode-remote <container_id>:/root/.vscode-remote
- Now you can connect to the target server from your local machine using VSCode Remote SSH, and you can also attach to the container after connecting to the server.
⚠️ Note that each time you update your local VSCode, you need to first connect to another linux server and then repeat the above steps to copy the ~/.vscode-server
directory to the target server or container.
3. Method 2: Install Manually
- 😵💫 This is a relatively complex method, recommended only if you cannot use Method 1!
- Moreover, this method does not support installing extentions in your target server or container.
- To use extentions, you will have to copy the
~/.vscode-server/extenstions
directory on another server to the target machine manually and then modify~/.vscode-server/extensions/extensions.json
, replacing all the extention paths to a correct path based on your environment.
3.1. VSCode Version and Commit-ID
If your vscode binary is in env:PATH
, you can get the version and commit-id by running the following command:
|
|
Or if not, open vscode, click Help
=> About
. Find the version and commit-id in the pop-up window:

3.2. Case A: If Your VSCode Version is Less than 1.19
(e.g, 1.18.1
)
Download vscode-server-linux-x64
with the following link and send it to the target server:
|
|
Now login to the the server with SSH on your local terminal:
|
|
Finally, go back to your local machine and connect to your server with VSCode Remote SSH, and everything should be okay.
3.2. Case B: If Your VSCode Version is Greater than 1.19
Download vscode-cli
with the following link and send it to the target server:
|
|
Now login to the the server with SSH on your local terminal:
|
|
Finally, go back to your local machine and connect to your server with VSCode Remote SSH, and everything should be okay.