Problem description
The ubuntu VM installed on the local PC can ping the VM network
$ping 172.16.0.4 ping 172.16.0.4 (172.16.0.4): 56 data bytes 64 bytes from 172.16.0.4: Icmp_seq =0 TTL =64 time=0.385 ms 64 bytes from 172.16.0.4: ICmp_seq =1 TTL =64 time=0.775 ms 64 bytes from 172.16.0.4: Icmp_seq = 2 TTL = 64 time = 0.697 msCopy the code
172.16.0.4 is the IP address of the Ubuntu VM. After logging in to the server using SSH, the login failed
$SSH [email protected] SSH: connect to host 172.16.0.4 port 22: Connection refusedCopy the code
Problem analysis
If the VM can be pinged from the local PC, the network connection between the VM and the local PC is normal. Then there may be SSH service problems, using Telnet in the virtual machine to try to connect to port 22
$Telnet 127.0.0.1 22 Trying 127.0.0.1... telnet: Unable to connect to remote host: Connection refusedCopy the code
If port 22 is disconnected, the SSH service may not be started. Check the SSH service status
$ systemctl status sshd
● sshd.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
Copy the code
No such file or directory indicates that the service is not installed
Problem solving
Installing the SSH Service
$ sudo apt-get install openssh-server
Copy the code
After the Openssh-Server is installed, check the SSHD service status
$ systemctl status sshdLow SSH. Service - OpenBSD Secure Shell server the Loaded: the Loaded (/ lib/systemd/system/SSH. The service; enabled; vendor preset: enabled) Active: active (running) since Sat 2021-02-20 04:07:24 PST; 17min ago Main PID: 6437 (sshd) CGroup: / system. Slice/SSH service └ ─ 6437 / usr/sbin/SSHD Feb 20 04:07:24 172 - D systemd [1] : Starting OpenBSD Secure Shell server... Feb 20 04:07:24 SSHD [6437]: Server Listening on 0.0.0.0 port 22. Feb 20 04:07:24 SSHD [6437]: Server listening on :: port 22. Feb 20 04:07:24 172 systemd[1]: Started OpenBSD Secure Shell server.Copy the code
In this case, the SSHD service starts normally, and the local host logs in to the VM using SSH
$SSH [email protected] [email protected]'s password:Copy the code
You are required to enter the password to verify that the SSH service is normal
The public,
Follow the public account: Huangxy, learn and progress together