ssh:连接到主机*端口 22:连接超时

ssh:连接到主机*端口 22:连接超时

我在 VPS 机器上运行着 CentOS 7,计算机重启后,我无法再通过 SSH 连接到它。

$ ssh -v <IP>
OpenSSH_6.6.1, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to <IP> [<IP>] port 22.
debug1: connect to address <IP> port 22: Connection timed out
ssh: connect to host <IP> port 22: Connection timed out

我尝试 ping 但没有任何反应。

$ ping <IP>
PING sidious (<IP>): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1

traceroute 输出了一些内容,但从未完成,最终以

$ traceroute sidious
traceroute to sidious (37.205.11.241), 64 hops max, 52 byte packets
1  192.168.1.254 (192.168.1.254)  0.664 ms  0.457 ms  0.457 ms
...
9  * * *
10  * * *
11  * * *
12  * * *

问题是,在 VPS 管理网站上,我可以在控制台上登录。我尝试确保 SSH 已启动,我相信它已启动。

我暂时禁用了 iptables。

$ iptables -L -n                                           
Chain INPUT (policy ACCEPT)                                                   
target     prot opt source               destination                          

Chain FORWARD (policy ACCEPT)                                                 
target     prot opt source               destination                          

Chain OUTPUT (policy ACCEPT)                                                  
target     prot opt source               destination        

最后,我还联系了我的 VPS 的服务器管理员,希望他们能提供帮助。但无论如何,如果有人能在这里提供帮助,我还是会写信的。

我认为这可能是网络问题。也许我不小心影响了它。

$ ss -tulpn                                                
Netid  State      Recv-Q Send-Q     Local Address:Port       Peer Address:Port

tcp    LISTEN     0      0                      *:22                    *:*   
users:(("sshd",420,3))                                                     
...                                               
tcp    LISTEN     0      0              127.0.0.1:25                    *:*   
users:(("master",1367,13))                                                 
...                                              
tcp    LISTEN     0      0                     :::22                   :::*   
users:(("sshd",420,4))                                                     
...

对于如何解决此问题还有其他想法吗?

答案1

所以最终还是网络问题。显然,因为我意外运行了yum update,系统升级到了 CentOS 7.1。此服务器实例在 OpenVZ 上运行,它有一个已知的与网络相关的错误https://bugzilla.redhat.com/show_bug.cgi?id=1207975

该链接还记录了修复方法:

--- ifup-aliases.orig   2015-04-01 08:46:08.179879018 +0200
+++ ifup-aliases    2015-04-01 08:46:52.558427785 +0200
@@ -261,7 +261,8 @@
            is_available ${parent_device} && \
            ( grep -qswi "up" /sys/class/net/${parent_device}/operstate || grep -qswi "1" /sys/class/net/${parent_device}/carrier ) ; then
                echo $"Determining if ip address ${IPADDR} is already in use for device ${parent_device}..."
-                  if ! /sbin/arping -q -c 2 -w ${ARPING_WAIT:-3} -D -I ${parent_device} ${IPADDR} ; then
+                  /sbin/arping -q -c 2 -w ${ARPING_WAIT:-3} -D -I ${parent_device} ${IPADDR}
+                  if [ $? = 1 ]; then
                   net_log $"Error, some other host already uses address ${IPADDR}."
                   return 1
               fi

进行更改(使用远程控制台)并重新启动服务器后,它就可以正常工作了,并且我已经能够通过本地机器上的 SSH 进行连接。

相关内容