When using Xshell to link the Linux in the virtual machine VM, the link fails and reports
Could not connect to '192.168.80.129' (port 22): Connection failed
Solution steps:
1. Restart VM, Linux, Xshell
2. If the restart is not resolved, ping the Linux IP from the local command line
C:\Users\Administrator>ping 192.168.80.129
3. If the local command line ping is successful, go to step 5.
C:\Users\Administrator>ping 192.168.80.129 Pinging 192.168 . 80.129 has 32 bytes of data:Reply from 192.168.80.129 : bytes = 32time = 1ms TTL = 64Reply from 192.168.80.129:bytes=32time<1ms TTL = 64Reply from 192.168.80.129:bytes=32time<1ms TTL = _ _ 64 Reply from 192.168.80.129 : bytes = 32 time < 1ms TTL = 64 Ping stats for 192.168 . 80.129 : Packets: Sent = 4 , Received = 4 , Lost = 0 ( 0 % lost), Estimated time of round trip in milliseconds: Shortest = 0ms, Longest = 1ms, Average = 0ms
4. The local command line ping fails, check the Linux network, specifically: enter ifconfig under Linux, but the IP cannot be found at this time. Next, execute vi /etc/sysconfig/network-scripts/ifcfg-eth0. After opening the file, it is found that the file is empty. This may be because the file was accidentally deleted. Enter the following information into this file:
DEVICE=eth0 ONBOOT=yes BOOTPROTO=static IPADDR=192.168.80.129 NETMASK=255.255.255.0 GATEWAY=192.168.80.2
The IPADDR is set according to your own needs. I set the IP of the virtual machine private network to the 80 network segment. Here, my IPADDR is set to 192.168.80.129, and the GATEWAY is set to 192.168.80.2
After setting, save and exit.
At this point, enter ifconfig again, and you can view the IP address.
5. Turn off the linux firewall
service iptables stop
chkconfig iptables off
6. Start the ssh service
service sshd start
If the startup is unsuccessful, you need to install ssh
Install ssh:
yum install openssh-server
Start the ssh service: service sshd start
Shut down the ssh service: service sshd stop
Restart the ssh service: servcie sshd restart
The SSH service starts automatically at boot: chkconfigsshd on
Cancel the boot self-start: chkconfig sshd off
After starting the service, check the service status: service sshd status
7. In Windows, open the command line and the following information appears
C:\Users\Administrator>ping 192.168.80.129 Pinging 192.168 . 80.129 has 32 bytes of data:Reply from 192.168.80.129 : bytes = 32time = 1ms TTL = 64Reply from 192.168.80.129:bytes=32time<1ms TTL = 64Reply from 192.168.80.129:bytes=32time<1ms TTL = _ _ 64 Reply from 192.168.80.129 : bytes = 32 time < 1ms TTL = 64 Ping stats for 192.168 . 80.129 : Packets: Sent = 4 , Received = 4 , Lost = 0 ( 0 % lost), Estimated time of round trip in milliseconds: Shortest = 0ms, Longest = 1ms, Average = 0ms
Indicates that the connection is successful
8. At this time, connect to the local linux again through xshell, and you can succeed.