Home>Article>Operation and Maintenance> What to do if centos ssh fails to connect

What to do if centos ssh fails to connect

藏色散人
藏色散人 Original
2022-01-27 16:06:18 25171browse

The solution to centos ssh failure to connect: 1. Install "openssh-server"; 2. Remove the # number before the listening port and listening address; 3. Enable the sshd service; 4. Open "ICMPv4-in "That's the rule.

What to do if centos ssh fails to connect

The operating environment of this article: CentOS 7 system, DELL G3 computer

What should I do if centos ssh cannot connect?

linux centos7 cannot connect to ssh

When centos7 connected to ssh, I referred to the following blog post and finally solved it perfectly

1,First, make sure CentOS7 hasopenssh-serverinstalled, enteryum in the terminal list installed | grep openssh-server

#Hereshows that it has been installedopenssh-server. If there is no output, it means thatopenssh-serveris not installed. Enteryum install openssh-server

##to proceedInstallopenssh-server##2,

Found the sshd service configuration file in the/etc/ssh/directorysshd_config, open it with Vim editor

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

Then enable remote login

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 start

##Check whether the sshd service is running Turn on, enter

ps -e | grep sshd

##orEnternetstat -an | grep 22Check ## Whether port #22is enabled for monitoring

##4,

In Vmware Workstation, Check the properties of CentOS7 and find that the network connection method isNAT.

5

,In Vmware Workstation,ClickEdit=》Virtual Network Editor, enter the virtual network editor, and check the NAT mode The network adapter name used for the connection isVMnet8

##6

,

In the windows host, enteripconfig in the command lineView the host IP and find the connection information of VMnet8. The ip here is192.168.30.1

7

In CentOS, enterifconfigto view the network Connect the address and find that the network address of CentOS is192.168.112.128

##8.in CentOS , enterping 192.168.30.1

to test whether the host can be connected, and find that it cannot be connectedIn the host, enter ping 192.168.112.128 to test whether Can connect to centos, found that it can be connected

##The next operation is: turn off the Linux firewall, found that the host can be pinged, indicating that the firewall is blocking

After checking the information, I found out thatIt turned out thatWindows firewall was not turned on

ICMPv4-inThis ruleOpen the firewall settings, select Advanced Settings, Inbound Rules, and set theprofile type to "Public""

File and Print Sharing (Echo Request – ICMPv4-In

)"rule, set to Allow.

After the setting is completed, it is found that the connection can be made normally

9.In order to avoid each The first time you start CentOS, you must manually start the sshd service. You can add the sshd service to the auto-start list and entersystemctl enable sshd.service

You can view it by enteringsystemctl list-unit-files | grep sshdWhether the sshd service auto-start is enabled

## Recommended: "

centos usage tutorial"

The above is the detailed content of What to do if centos ssh fails to connect. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn