The virtual machine centos and the host ping each other

In the virtual machine (Vmware Workstation), CentOS7 is installed, and now I want to connect to CentOS7 in the virtual machine through the SSH tool

1、 First of all, to ensure that CentOS7 has installed openssh-server, enter yum list installed | grep openssh-server in the terminal

If no output is displayed, it means it is not installed

Install by entering yum install openssh-server openssh-server

2、 Found the sshd service configuration file sshd_config in the **/etc/ssh/ ** directory, open it with the Vim editor

Remove the # sign before the listening port and listening address in the file

Then turn on allow remote login

Finally, turn on the use of username and password as connection authentication

Save the file and exit

3、 To start the sshd service, enter sudo service sshd start

To check whether the sshd service has been started, enter ps -e | grep sshd

Or enter **netstat -an | grep 22 ** to check whether port 22 is enabled for monitoring

4、 In Vmware Workstation, check the properties of CentOS7 and find that the network connection method is connected by NAT

5、 In Vmware Workstation, click Edit=》Virtual Network Editor, enter the virtual network editor, and check that the network adapter name used for the NAT mode connection is VMnet8

6、 In the windows host, enter **ipconfig ** in the command line to view the host IP and find the connection information of VMnet8, where the ip is 192.168.30.1

7、 In CentOS, enter ifconfig to view the network connection address, and find that the network address of CentOS is 192.168.112.128

8、 In CentOS, enter ping 192.168.30.1 to test whether the host can be connected and found that it can be connected

9、 In the host, enter ping 192.168.112.128 to test whether the host can connect to CentOS, and it is found that the connection cannot be reached

If you can connect, you can skip to step 12

10、 On the host, open the network configuration, select the TCP/IPv4 properties of the network adapter VMnet8, and perform the following network configuration

The subnet mask and default gateway are required to be consistent with CentOS, and the IP address is changed to 192.168.112.1, which means that the IP of the host and the IP of CentOS are in the same network segment

11、 Then in the host, enter ping 192.168.112.128, it can be connected

12、 In the SSH tool (XShell used here), create a new connection and enter the IP address, username, and password of CentOS to connect successfully

connection succeeded

13、 In order to avoid having to manually start the sshd service every time you start CentOS, you can add the sshd service to the self-starting list and enter systemctl enable sshd.service

You can enter systemctl list-unit-files | grep sshd to check whether the sshd service self-starting is enabled

Recommended Posts

The virtual machine centos and the host ping each other
CentOS7.2 and Nginx configuration virtual host
Uboot and dual-system Ubuntu 18.04 ping each other
Download of VM virtual machine and install centos7
CentOS 7 install KVM and create a virtual machine
Analysis on the method of CentOS8 virtual machine to access Windows10 host folder
Install KVM on CentOS 7 and create a virtual machine
Linux CentOS 7 virtual machine clone
VMwareWorkstation10.0 install CentOS7.0 virtual machine
CentOS 6.8 virtual machine installation details
The difference between CentOS 7 and CentOS 6
Xshell and Xftp fail to connect to the virtual machine Ubuntu
The difference between CentOS and Ubuntu
The difference and connection between Centos and Redhat
Install Ubuntu 18.04 in the virtual machine VMware
Install CentOS7 virtual machine, configure docker suite
Centos7 configuration host name and IP address
Build Nginx based on Centos 7 (including virtual host)
VMware Fusion install CentOS7 and configure the network
Virtual machine installation and configuration ubuntu shared folder_
Use Ubuntu and windows system in virtual machine