Xshell solve the connection centOs7 Could not connect to '? ? ? '(Port 22): Connection failed.

Xshell solve the connection centOs7 Could not connect to '? ? ? '(Port 22): Connection failed.

Encounter Could not connect to '192.168.119.129' (port 22) when connecting centos7 with Xshell:. Connection failed this problem, my solution is as follows:

Step1. Obtain an IP address of centos7

Enter "ip addr" after landing acquire ip address, ip if acquired as follows, indicating that at this time your centsOs7 not yet been assigned an IP address can connect.

At this time, need to enter the command "cd / etc / sysconfig / network-scripts" enter "ls" command into the network-scripts, see the situation shown below:

Enter the command "vi ifcfg-eno16777736" will edit the file last changed yes, press the "esc" key to exit edit mode after the change and then enter ": wq" to save and exit (note the colon).

Restart the virtual machine exit, enter "ip addr" again, the situation will appear as shown:

This shows that you can use "192.168.119.129" this ip connection virtual machine.

This can be used when xShell connect again, if the problem still appears as follows:

Step2: Check the virtual machine to install SSH Server

Input command | after "rpm -qa grep ssh" If the situation appears as shown below explained installed SSH service, this does not occur if the following needs to execute the command "yum yum install openssh-server" installation.

Step3. Modify the sshd_config file

执行命令" vi /etc/ssh/sshd_config",同样也是按" i " 进入编辑模式,将端口号、监听端口,允许root用户登陆 前边的 " # " 去掉

最后 开启用户名密码作为连接验证

以上都改好之后 保存并退出

Step4. 输入" sudo service sshd start " 命令开启 sshd 服务

Step5. 输入” ps -e | grep sshd “ 检查 sshd 的服务是否开启,如果出现下图这种情况说名开启成功

Step6 .在 VMware 中检查虚拟机的网络连接方式,设置为NAT方式,如图所示:

Step7.在VMware中点击”编辑“ 发现NAT 模式的名称为VMnet8

Step8. 在windows主机中输入" ipconfig " 发现VMnet8 的 ip 如下:

Step9.在windows主机中输入" ping 192.168..119.1" 则会出现下图这种情况

在centOs中输入"ip addr" 会发现他的 ip 为" 192.168.119.129" 如果ping它的ip地址不成功则进行下面的操作

Step10. 打开电脑的 " 网络和共享中心 " 设置 VMnet8 的ip地址,如图所示:

要求子网掩码、默认网关均和CentOS一致,并将IP地址修改为 192.168.119.1,即保证主机的 IP 和 CentOS 的 IP 在同一网络区段中,设置后再次在主机中ping centOS 的 ip 发现即可成功。

Step11. 使用xShell 连接即可。

Guess you like

Origin www.cnblogs.com/moox/p/12110075.html