# 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

### Mandatory

• Visual Studio Code --Bottom of page .zip Download 64bit or 32bit or better. --Expand it in a suitable place.

### 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
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


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


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).