Remote development with VSCode and SSH

Remote development with VSCode and SSH

0. Why do we need remote development?

When developing embedded Linux, for convenience, code is usually edited using a code editor on Windows, and the cross-compilation tool is on a Linux virtual machine or server. During development, the following loop operations need to be performed continuously:

  • After editing the code, upload the file to the server using SCP based on SSH;
  • Use the SSH remote terminal to compile an executable file on the server;
  • After the compilation is complete, use SCP based on SSH to transfer the file back to the local computer;

These operations are all based on SSH, but they require terminal software, file transfer software, and constant switching operations, which makes the process very troublesome.

If the local editor can directly open the remote server directory, operate files, and execute commands through SSH, this is called remote development. Using remote development can greatly facilitate our development process.

1. Visual Studio Code Remote – SSH extension

Remote Development extension pack is an extension released by VS Code in May this year. The extension includes three extensions:

  • Remote - SSH
  • Remote - Containers
  • Remote - WSL

These three extensions support using remote computers, containers, or Windows Subsystem for Linux (WSL) as a fully functional background development environment. The local VS Code is just a front-end interface. In this article, we will mainly describe how to use the SSH extension, as shown in the figure:

2. SSH extension installation

2.1. Make sure you can use the ssh command on the command line

If the system you are using is Windows10 , the system already has SSH installed, and you cannot use Git's SSH anymore: as shown in the figure:

If you are using Windows7 , you cannot install OpenSSH. You can only use the ssh command in Git. Add the usr\bin folder in the Git installation directory to the system environment variable. This directory contains the executable program of the ssh command.

2.2. Install Visual Studio Code Insiders version

Note:

  • Since VScode1.35 1.35, the SSH extension has entered the stable version. You can use the extension normally and jump directly to Section 2.3.
  • If VS Code is lower than this version, you need to install the VS Code beta version;

The VS Code remote development extension is still in preview, so you need to download and install Visual Studio Code Insiders (download link), which is the internal test version of VS Code, and then install it:


2.3. Install SSH extension

Search for remote in the VS Code extension market, select Remote-SSH , and click Install:


3. Install SSH server on remote host

! ! !
Special note: SSH extension can only connect to 64-bit Linux operating system.
! ! !
Install ssh server on remote Linux host:

sudo apt-get install openssh-server

4. Use SSH extension

4.1. Set up SSH extension to display login terminal

Open the command palette, enter ssh , and select settings:


4.2. Start SSH to connect to the remote host

There are two ways to start SSH:

Use Ctrl+Shift+P to open the command palette, enter ssh , and select Connect to Host :

Simply click the ssh icon in the lower left corner:

After startup, enter the username and IP address of the remote host and press Enter to connect:

So the SSH login terminal will be displayed, just enter the user's password:

After logging in for the first time, VS Code will automatically pop up a new window for remote work and automatically install the VS Code server on the remote host:


During the login process, you need to constantly enter the password. Just enter the password when it pops up, as shown in the figure:


After successful login, as shown below:

4.3. Open a remote directory as a workspace

Click on the File view:


Then select the directory to open:


Open successfully as follows:

4.4. Using the Remote Terminal

Simply click on the new terminal to open Bash:

4.5. Installing extensions

Note that in remote development, extensions are divided into local extensions and remote extensions:

5. Remember frequently used hosts

As shown in the figure, open the configuration file:


Select a profile:


Fill in the content in the following format and save:


This is the end of this article about using VSCode and SSH for remote development. For more relevant VSCode and SSH remote development content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to use ssh key to remotely log in to the server without secrets in VSCode
  • VSCode remote SSH password-free login configuration implementation
  • Solution to installing librosa to process audio in vscode ssh

<<:  JavaScript to achieve all or reverse selection function

>>:  Example analysis of the search function of MySQL regular expressions (regexp and rlike)

Recommend

JS realizes the effect of picture waterfall flow

This article shares the specific code of JS to re...

Six ways to increase your website speed

1. Replace your .js library file address with the...

The perfect solution for Vue routing fallback (vue-route-manager)

Table of contents Routing Manager background gett...

Pure CSS to change the color of the picture

The css technique for changing the color of an im...

Analysis of the advantages of path.join() in Node.js

You might be wondering why you should use the pat...

Win10 + Ubuntu 16.04 dual system perfect installation tutorial [detailed]

Be sure to remember to back up your data, it is p...

Record of the actual process of packaging and deployment of Vue project

Table of contents Preface 1. Preparation - Server...

The whole process record of vue3 recursive component encapsulation

Table of contents Preface 1. Recursive components...

CSS Back to Top Code Example

Most websites nowadays have long pages, some are ...

What does the "a" in rgba mean? CSS RGBA Color Guide

RGBA is a CSS color that can set color value and ...

Summary of common MySQL commands

Set change mysqlroot password Enter the MySQL dat...

Summary of basic usage of js array

Preface Arrays are a special kind of object. Ther...

The complete usage of setup, ref, and reactive in Vue3 combination API

1. Getting started with setUp Briefly introduce t...