Solution to the problem that centos cannot access ssh:
1. First, make sure CentOS7 has openssh-server installed and enter # in the terminal. ##yum list installed | grep openssh-server
openssh-server has been installed. If there is no output, Indicates that
openssh-server is not installed. Install
openssh-server by typing yum install openssh-server
sshd_config in the
/etc/ssh/ directory and open it with Vim editor
## Finally, enable the use of username and password as connection verification
Save the file and exit
3. Start the sshd service and enter
sudo service sshd startCheck whether the sshd service has been started, enter
ps -e | grep sshdOr enter
netstat -an | grep 22Check whether port 22 is open for listening
4. In Vmware Workstation, check the properties of CentOS7 , it is found that the network connection method is connected by NAT method
5. In Vmware Workstation, click Edit => Virtual Network Editor, enter the virtual network editor, and view It is found that the network adapter name used in 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. The ip here 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. If you find that you cannot connect to the host, enter ping 192.168.112.128 to test whether you can connect to centos. It is found that the connection can be connected. The next operation is: turn off the Linux firewall and find that the host can be pinged. It means that the firewall is blocking it.After checking the information, it turns out that the Windows firewall has not turned on the ICMPv4-in rule
Open the firewall settings, select Advanced Settings, Inbound Rules, and set the "File and Print Sharing (Echo Request – ICMPv4-In)" rule with the configuration file type "Public" to Allow.
After the setting is completed, it is found that the connection can be normal
9. In order to avoid having to manually start the sshd service every time you start CentOS, you can use sshd Add the service to the auto-start list, enter
systemctl enable sshd.serviceYou can enter
systemctl list-unit-files | grep sshd ,Check whether the sshd service auto-start is enabled.
Recommended tutorial: "
centos tutorialThe above is the detailed content of What should I do if centos cannot access ssh?. For more information, please follow other related articles on the PHP Chinese website!