What to do if centos ssh fails to connect

藏色散人
Release: 2022-01-27 16:07:13
Original
25445 people have browsed it

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 has openssh-server installed, enter yum in the terminal list installed | grep openssh-server

#Here shows that it has been installed openssh-server. If there is no output, it means that openssh-server is not installed. Enter yum install openssh-server

##to proceed Install openssh-server##2,

Found the sshd service configuration file in the /etc/ssh/ directory sshd_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

##or Enter netstat -an | grep 22 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 NAT.

5

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

##6

,

In the windows host, enter ipconfig in the command line 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 Connect the 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 find that it cannot be connected In 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 that It turned out that Windows firewall was not turned on

ICMPv4-in This rule Open the firewall settings, select Advanced Settings, Inbound Rules, and set the profile 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 enter systemctl enable sshd.service

You can view it by entering systemctl list-unit-files | grep sshd Whether 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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template