Use SSH to connect to the virtual machine Ubuntu under the physical machine Windows system

Required environment

Step 1: Install ssh server on Ubuntu

xshellThe remote connection ubuntuis through the ssh protocol, so you need to ubuntuinstall the ssh server

sudo apt-get install openssh-server

Insert picture description here
Check if the ssh service is started ps -e |grep ssh

If it is started, the process in the figure below will be displayed

Insert picture description here
If you don't need to start the ssh service, enter service ssh start
Insert picture description here

Or just restart the ssh service

sudo service ssh restart

Command to modify SSH configuration file

 vi /etc/ssh/ssh_config 

Insert picture description here
Insert picture description here

Step 2: Install Xshell on Windows

Xshell can be downloaded directly from the official website:
https://www.xshellcn.com/

The third step: mutual ping (because the ssh remote connection is connected through the network, if the network is not connected, it will not be able to connect.)

The virtual machine and the physical machine need to be able to ping each other. If there is no way to ping each other, then there is no way to connect remotely. It feels like the following two points:

  1. The virtual machine Ubuntu needs to be networked: you can refer to my blog, Ubuntu configuration static ip networking summary
  2. Pay attention to the firewall between the two, remember to open port 22 of the virtual machine (the default port number of the SSH server)

Actual operation

Ubuntu

After finishing the upper environment

Windows (the first login method to create a new session)

Insert picture description here
Create a new session,
Insert picture description here

As long as the required environment is complete , then the host will fill in the ip of the virtual machine Ubuntu. Do not change the default port number. Use SSH for the protocol. This screen will appear for the rest.
Insert picture description here
Fill in the password, and then log in.
Insert picture description here

Windows (second login method)

Insert picture description here
Command line mode:

ssh 用户名@ip

Then there will be a pop-up that needs to enter the password corresponding to the user name.

note

Under the Ubuntu operating system, you must remember to install the ssh server , otherwise this error is always reported in the figure below.
Insert picture description here

note

When typing a command in xshell, if you type the wrong letter, you want to delete the wrong letter by pressing the backspace key, but it is displayed on the screen “^H”, and the backspace does not work. Press the delete key again, but it shows “^[[3~”that it can’t be deleted. The wrong letter.

The first way

Modification method: File -> Open -> Properties -> Terminal -> Keyboard, change the delete and backspace sequence to ASCII 127.

Insert picture description here

Insert picture description here

The second way

Because the Shell used here is dash, the operation is not as convenient as the bash in Ubuntu. You only need to change the user login shell:

The Shell used for login is the terminal command used after the login command. Ubuntu defaults to bash
Insert picture description here

As follows, this is the biaobiaouser dashinterface,
Insert picture description here

Insert picture description here
Insert picture description here

Change to bashafter

sudo usermod -s /bin/bash biaobiao

Then after reconnecting:
Insert picture description here
Insert picture description here

Becomes exactly the same as Ubuntu, and the operation is very convenient

Guess you like

Origin blog.csdn.net/CSNN2019/article/details/115257418