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

Details of Linux file descriptors, file pointers, and inodes

Table of contents Linux--File descriptor, file po...

jQuery realizes the scrolling effect of table row data

This article example shares the specific code of ...

JavaScript realizes the effect of mobile modal box

This article example shares the specific code of ...

MySQL high availability solution MMM (MySQL multi-master replication manager)

1. Introduction to MMM: MMM stands for Multi-Mast...

Practical TypeScript tips you may not know

Table of contents Preface Function Overloading Ma...

JavaScript to achieve skin effect (change background)

This article shares the specific code of JavaScri...

Docker nginx implements one host to deploy multiple sites

The virtual machine I rented from a certain site ...

Implementation of element input box automatically getting focus

When making a form in a recent project, I need to...

How to build a redis cluster using docker

Table of contents 1. Create a redis docker base i...

Simple example of HTML text formatting (detailed explanation)

1. Text formatting: This example demonstrates how...

Detailed explanation of mysql scheduled tasks (event events)

1. Brief introduction of the event An event is a ...

Double loading issue when the page contains img src

<br />When the page contains <img src=&qu...

How to manually upgrade the kernel in deepin linux

deepin and Ubuntu are both distributions based on...

MySQL 5.7 installation and configuration method graphic tutorial

This tutorial shares the installation and configu...