[VScode remote connection virtual machine (ubuntu)]


foreword

Record some of the problems you encountered during the remote connection process


1. Install VScode

Software link (there are stable version and developer version, it is recommended to install the stable version, because the developer version may encounter some bugs): vscode official website

2. Install the Chinese plug-in

First, after successfully installing vscode, open the interface as follows:
This is the effect after installing the Chinese plug-in. If you
have not installed it, you can install it according to the following steps:
insert image description here
insert image description here
enter Chinese in the search box in the upper left corner, and then click install. After the installation is complete, there will be a prompt in the lower right corner. Restart vscode and click restart, and then it will become a Chinese interface.

3. Install other remote connection plug-ins

Follow the above steps to go to the search box for installed plugins and install the following plugins:

1.C/C++ Extension Pack

C/C++ Extension Pack

insert image description here

2.Live Preview

Live Preview

insert image description here

3.Live Server

Live Server

insert image description here

4.Remote Development

Remote Development

insert image description here
This plug-in is a necessary plug-in for remote connection. After the plug-in is installed, the following window will appear:
insert image description here

Fourth, configure the virtual machine

1. Install ssh

The ubuntu22 virtual machine I use will appear after entering ssh in the terminal:
insert image description here
Although it does not say that there is no ssh, an error will still occur when I try to connect remotely, so it is recommended to install ssh directly.
Be lazy. This blog talks about the installation of ssh in more detail. Please refer to the following steps for the detailed steps of installing SSH on the virtual machine.

2. The host and the virtual machine can ping each other

Open the terminal and enter ifconfig

ifconfig

insert image description hereThe ip address behind inet in the figure is the ip address of the virtual machine
, and then enter ipconfig on the windows host

ipconfig

insert image description here
Find the IPv4 address, which is the ip address of the host, and use the virtual machine to ping each other with the host:

ping ip地址

The virtual machine pings the host,
insert image description here
the host pings the virtual machine,
insert image description here
and the basic work is ready here

5. Use vscode to connect to the virtual machine

1. Open vscode and follow the steps below

insert image description here
insert image description here
insert image description here

Enter ssh virtual machine username@virtual machine ip address

ssh user@ip

insert image description here
insert image description here
insert image description here

insert image description here

Host 端口名默认是IP地址(可以自己任意定义)
  HostName 虚拟机ip地址
  User 虚拟机用户名

The approximate steps here are completed.

2. Connect

insert image description here
If there is a port name in the lower left corner, the connection is successful.


Summarize

There are a lot of specific steps, and there are many problems. Everyone has different methods and different problems.
For example, there will be a process of entering a password during the connection process. It is cumbersome to ask for a password every time you connect, so I use the key login method, and you don’t need to enter a password when you connect later. If you need it, you can refer to this. Blog
VsCode configures ssh password-free remote login .
There will definitely be problems, but you have to constantly try and make mistakes, and then change them, so as to avoid unsolvable problems when subsequent problems arise.
Therefore, the revolution has not yet succeeded, and comrades still need to work hard
| ᐕ)⁾⁾ See you next time

Guess you like

Origin blog.csdn.net/qq_57903239/article/details/127499784