当前位置:网站首页>Vscode usage - Remote SSH configuration description

Vscode usage - Remote SSH configuration description

2022-06-26 17:23:00 jackailson

By: Ailson Jack
Date: 2022.06.17
Personal blog :http://www.only2fire.com/
The address of this article on my blog is :http://www.only2fire.com/archives/147.html, Better layout , Easy to learn , You can also visit my blog , There may be something you want .

My environmental description :

  • The local environment :Windows 11
  • distal environment :Ubuntu 22.04 LTS( Running in a virtual machine )

Remote-SSH brief introduction

Remote-SSH It's a VSCode Plug in for ,Remote-SSH Can let you use any with SSH Serve the remote machine as your development environment . This can greatly simplify development and troubleshooting in various situations . Used Remote-SSH After the plug-in , You can :

  • Develop on the same operating system you deploy , Or use a larger computer than the local computer 、 Faster or more specialized hardware .
  • Fast switch between different remote development environments , And update it safely , Without worrying about affecting your local computer .
  • Access existing development environments from multiple computers or locations .
  • Debugging in other places ( Such as customer site or cloud ) Running applications .

Remote-SSH Installation and environmental preparation

First installation VSCode, Then search in the extension "Remote", Install the found "Remote-SSH" and "Remote-Containers","Remote-SSH: Editing Configuration" The plug-in will be installed "Remote-SSH" Automatically install plug-ins :

 Insert picture description here
Ensure that the remote environment (Ubuntu 22.04 LTS) in SSH Service available .

Ensure that... Is supported in the local environment SSH, This can be done by installing Git To get SSH function .

SSH The key configuration

This section will be in Windows Generate on SSH secret key , And then deploy to Ubuntu 22.04 LTS In the system , So every time you restart VSCode after , Use Remote-SSH visit Ubuntu 22.04 LTS Files in the system , No need to enter the password manually .

Generate SSH The key file

stay Windows Execute the following commands on the system to generate SSH secret key :

ssh-keygen

After entering the above command , When waiting , Directly by ENTER The key remains the default , Knocking required 3 Time ENTER key , Then it will be in C:\Users\AilsonJack\.ssh In the table of contents SSH The key file :id_rsa and id_rsa.pub.

Deploy the key file to Ubuntu

First , Ensure that the current user exists in the user directory .ssh Catalog ( My full path here is :/home/ailsonjack/.ssh ), Execute the following order , Check whether there is... In the output information .ssh Catalog :

ls -al ~

If it doesn't exist .ssh Catalog , Then execute the following command to create :

mkdir ~/.ssh

adopt FTP,SFTP,samba And so on id_rsa.pub File transfer to Ubuntu 22.04 LTS In the system /home/ailsonjack/.ssh Directory .

Generate authorized_keys file

Get into /home/ailsonjack/.ssh Catalog , Then use the following command , Generate authorized_keys file :

cat id_rsa.pub > authorized_keys

Remote-SSH To configure

The following will describe Remote-SSH Some configuration of , complete Remote-SSH After configuration , You can go through Remote-SSH visit Ubuntu 22.04 LTS Files or folders in the system , It's like developing on a local computer .

open VSCode, Then click on the “ Remote Explorer ” Icon , Then click on the pinion in the upper right corner ( Set up ):

 Insert picture description here
In the pop-up window , Choose the first , open config file , Then fill in the configuration information :

 Insert picture description here
 Insert picture description here
The text of the configuration information is as follows :

Host Ubuntu22.04
    HostName 192.168.1.5
    User ailsonjack
    IdentityFile C:\Users\AilsonJack\.ssh\id_rsa

Notes to the above configuration information are as follows :

Host < Remote host name >
    HostName < Remote host IP>
    User < user name >
    IdentityFile < This machine SSH Private key path >

After the above configuration , Get into “ Remote Explorer ” Options , Right click on the host name , And then choose “Connect to Host in Current Window” perhaps “Connect to Host in New Window”:

 Insert picture description here
If the connection is successful , The lower left corner will display the currently connected host name :

 Insert picture description here
Click on “ Open folder ” Can open Ubuntu Folder in the system , I opened it here Ubuntu In the system Linux Kernel folder , At this point we can be in Windows In the system , utilize VSCode Of Remote-SSH Plug in reading Ubuntu In the system Linux Kernel source code , Isn't it cool :

 Insert picture description here

Install the plug-in to the remote system

When we're done with Remote-SSH After configuration ,VSCode Support in remote server Installing a plug-in . At this point, we can install plug-ins to the remote system according to our own needs , You can also install all local plug-ins to the remote system with one click :

 Insert picture description here
Click the icon in the red box in the above figure , You can install all the local plug-ins to the remote system with one click .

Welcome to the official account of bloggers. ( WeChat search official account : Embedded in those things ), You can scan the following official account QR code ( To prevent the QR code of official account from being CSDN Dispose of , Something is added around the QR code picture , If the official account picture is really CSDN Processed , You can also directly visit my personal blog post to get the QR code picture of the official account ):

 Insert picture description here
If there are any questions in the text, please correct them , After all, the level of bloggers is limited .

If this article helps you , Just remember to praise and pay attention to the blogger ^_^.

For better content, see my blog address :http://www.only2fire.com/archives/147.html

notes : Reprint please indicate the source , thank you !^_^

原网站

版权声明
本文为[jackailson]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261651370150.html