Introduce VS Code and Remote Development to an offline environment to make linux development comfortable

I want to use VS Code, but I don't have the internet in my development environment ... VSCode Remote Development It's very convenient, but the work environment is impossible ... I don't want to melt it for a day to google how to use vim, gdb and git commands anymore ... Give to the person.

Organize the situation at the development site

--Client (machine where you want to open VS Code) --Offline Windows --Actual offline is possible, such as in a proxy --OpenSSH mystery is not included (sometimes) --No administrator privileges (sometimes) ――Put VS Code here and use it! --Target (target development machine) ――It is troublesome to put VS Code directly in linux, and VNC and RDP are heavy. --Put vscode-server here! --Sshd, gcc and gdb are in here!

Point of solution

--Download the required plug-ins in advance --Manually get vscode-server corresponding to vscode version (commit) --Avoid the moss point wget in SSH Extention by changing it to cp

procedure

1. Download what you need

Download in advance what you need to deploy to an offline environment.

Mandatory

What to put in as needed

--Client  - OpenSSH --For those who do not have OpenSSH. --Expand it in a suitable place. - Japanese Language Pack for Visual Studio Code --English for people who don't like it. --Other plugins you want --Target machine --sshd: Make sure to accept ssh connections. --gcc: Necessary for compiling C / C ++. --gdb: Debugger. Those who need it for development.

2. Plugin into VS Code

Select Install from VSIX ... from the right shoulder of the plug-in list to install each downloaded plug-in. Let's google the method.

3. Set up ssh public key authentication

Let's google this step. In short:

  1. Client: Run ssh-keygen (ssh-keygen is in the OpenSSH folder). No need to enter a passphrase.
  2. Write the contents of id_rsa.pub generated on the client to ~ / .ssh / authorized_keys on the server
  3. Be careful with .ssh and authorized_keys permissions.
  4. Write config in ~ / .ssh / config on the client.
  5. Set ProxyCommand etc. as needed.
  6. Make sure that OpenSSH alone (ssh.exe) can be used for public key authentication.

~/.ssh/config example


Host target
HostName target IP address
User target login user
IdentityFile client id_Path to rsa

4. Check VS Code version

From the menu, go to Help> About and check Commit :. You can also copy.

Version: 1.43.1
Commit: fe22a9645b44368865c0ba92e2fb881ff1afce94
Date: 2020-03-18T07:01:20.184Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18362

5. Download vscode-server-linux-x64.tar.gz

Download vscode-server-linux-x64.tar.gz from the URL that contains the Commit.

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

6. Transfer the downloaded vscode-server-linux-x64.tar.gz to your target

The code below contains wget, which causes Remote Development to fail to launch. First of all, instead of wget, transfer the thing you got yourself to the target machine. Let's send it from the client to the target / tmp etc. by scp. (Scp is in the OpenSSH folder.) You can check the operation here as well to see if the public key authentication is set up properly.

.\scp \path\to\vscode-server-linux-x64.tar.gz target:/tmp

7. Remote-Ssh mods

Replace wget running on the target with the cp command and rewrite it as if wget was successful even in an offline environment. Edit ~ \ .vscode \ extensions \ ms-vscode-remote.remote-ssh-0.50.0 \ out \ extension.js on the client. I am changing the code that should be wget on the target to the code that is copied from / tmp.

extention.ja(original)


wget ${function(e){return e?"--tries=1":""}(!!m)} --connect-timeout=7 --dns-timeout=7 -nv -O vscode-server.tar.gz $DOWNLOAD_URL

extention.ja(After change)


cp /tmp/vscode-server-linux-x64.tar.gz vscode-server.tar.gz

That's all for the procedure. Let's check if we can connect to the target from VS Code. You can also put the plugin into the target from VS Code. You can also transfer the vsix file to the target and install it with Install from VSIX ...

trouble shooting

Cannot connect

--Check if the public key authentication of ssh.exe passes.

I get an error even though I get Got Connection 1

--Check sshd_config. - https://code.visualstudio.com/docs/remote/troubleshooting - AllowTcpForwarding yes - AllowStreamLocalForwarding yes --Check the target firewall (OUTPUT).

Refs -VSCODE remote development Connection in an environment where the remote host is not connected to the Internet -[VS Code] How to use the Remote Development function on a server without an Internet environment

Recommended Posts

Introduce VS Code and Remote Development to an offline environment to make linux development comfortable
How to make VS Code aware of the venv environment and its benefits
Cross-compiling Raspberry Pi and building a remote debugging development environment with VS Code
[Django] Use VS Code + Remote Containers to quickly build a Django container (Docker) development environment.
Create a VS Code + Docker development environment on a Linux VM
Comfortable LaTeX with Windows Subsystem for Linux and VS Code
Create a simple Python development environment with VS Code and Docker
How to build Python and Jupyter execution environment with VS Code
Let's do Linux System Programming with Visual Studio Code and Azure! (From helloworld to nginx development and remote debugging)
A complete guidebook to using pyenv, pip and python in an offline environment
How to make an embedded Linux device driver (11)
How to make an embedded Linux device driver (8)
How to make an embedded Linux device driver (1)
How to make an embedded Linux device driver (4)
How to make an embedded Linux device driver (7)
How to make an embedded Linux device driver (2)
How to make an embedded Linux device driver (3)
How to make an embedded Linux device driver (6)
Set up an Objective-C 2.0 development environment on Linux
How to make an embedded Linux device driver (5)
How to make an embedded Linux device driver (10)
How to make an embedded Linux device driver (9)
Make your Python environment "easy" with VS Code
Set up TinyGo development environment for VS Code
I tried to build an environment with WSL + Ubuntu + VS Code in a Windows environment
How to pass args or environment variables with Makefile and make command on #Linux
Steps to attach and debug from VS Code to Jupyter Lab on a remote server
How to make a Python package using VS Code
How to make an embedded Linux device driver (12) (Complete)
Remote debug Django environment created with docker-compose with VS Code
Ssh to virtual environment with remote development of vscode
[No venv required] The strongest Python development environment created with Remote Containers [VS Code / Docker]
Introduce serverspec to Linux
Pros and cons of converting Django's development environment to Docker
Add an extension to build a more comfortable Jupyter environment
[Linux] Compress folders and transfer files from remote to local
How to use VS Code in venv environment on windows
Build a Go development environment with VS Code's Remote Containers
Minimum Makefile and buildout.cfg to create an environment with buildout
Build a comfortable development environment with VSCode x Remote Development x Pipenv
UpNext2 Development Record # 1 Build Python CI environment in VS Code
I want to use VS Code and Spyder without anaconda! !! !!
[Windows 10] [Development environment construction] How to resolve when unresolved import'django.xxx' python (unresolved-import) occurs in VS Code