Use vscode ssh connection linux virtual machine

vscode adds support for ssh in the latest stable version, we can use ssh to connect to remote host expand development. Similarly, if we are in the windows environment, use ssh to connect linux linux virtual machine for seamless development under the windows, it is also possible.

Configure the virtual machine (server)

I will not install a virtual machine in detail, there are many online information in this regard. It is assumed that we have installed a linux virtual machine. I use virtualbox, we need to make some configuration of the network virtual machine.

Virtualbox virtual machine to be selected in the set, click Settings, click on the network, if no special settings during installation of the virtual machine, then the connection should be "Network Address Translation (NAT)", use this setting on the line. Expand the following "Advanced" option, click "port forwarding", create a forwarding rule, the name is called "ssh", agreement with "TCP", host IP and subsystem IP can empty not write, host port easily fill a not occupied port can I use here is 2201, the same port subsystem can also easily fill a port is not occupied, I have here it is 22.

So that our server is set up, we have the equivalent of a "server" on your machine. Then log on with a client.

Use ssh client connect virtual machines

win10 has built openssh, so a direct line can be used to log ssh command in the command. Linux really use graphical interface card in the virtual machine, so I do not have a graphical interface at installation, you can start using the free interface startup.

Open cmd, and so on, or whatever you like poweshell terminal, enter the command:

ssh user@localhost -p 2201

userIs the user you want to log on, localhostit indicates that this is a local environment, not like some online tutorial written, to see the operation ip like in the virtual machine. The key is -pbehind the port parameters to correct, here is set up in front of the host port , you will be prompted to enter the password after the carriage return, you can log in correctly.

Of course, if that operate in the command line is too much trouble, especially under the windows command line environment is indeed not very friendly, and you can also use a professional ssh client to log in, such as putty, mobaxterm.

Use vscode connect virtual machines

vscode provides the ability to ssh client through plug-ins. You need the latest version of vscode and remote-ssh plugin. After installation, vscode sidebar will be more than one such icon.

The system may require some configuration. Click on the left CONNECTIONS settings, there will be several configuration files, edit the first line, which is the default user profile. Configuration is also very simple, only three lines of the original, but it should be noted that if the host is not the default port 22, then you need to add the following line to the Portport to fill just set the host port .

Host name
    HostName localhost
    User username
    Port 2201

After clicking this icon lower left corner of the window, select Remote-SSH: connect to hostthe pop-up menu, select just written in the configuration file of the host, is automatically configured vscode. Wait a little while, the configuration is complete! Enjoy Linux development experience seamless environment of it in windows.

Guess you like

Origin www.cnblogs.com/gohugo/p/11419837.html