今天到公司后, 发现阿里云服务器远程连接不上了. 网站是正常访问无异常没报警. 试了下腾讯云的服务器可以连接. 排查啥原因吧, 先给阿里提工单再找原因.
问同事是否能连上, 排除个人电脑或远程软件原因. 同事都说连不上. 看了下个人阿里云账户的实例也是连不上. 是阿里云的问题? 问了下朋友他们公司同一区的阿里云服务器是否可以连接, 他们是可以的... 找原因吧
[root@local tmp]# ssh 106.14.27.54 ssh_exchange_identification: read: Connection reset by peer [root@local tmp]# ping 106.14.27.54 PING 106.14.27.54 (106.14.27.54) 56(84) bytes of data. 64 bytes from 106.14.27.54: icmp_seq=1 ttl=49 time=25.0 ms 64 bytes from 106.14.27.54: icmp_seq=2 ttl=49 time=24.9 ms 64 bytes from 106.14.27.54: icmp_seq=3 ttl=49 time=25.0 ms 64 bytes from 106.14.27.54: icmp_seq=4 ttl=49 time=24.7 ms 64 bytes from 106.14.27.54: icmp_seq=5 ttl=49 time=24.8 ms ^C --- 106.14.27.54 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4429ms rtt min/avg/max/mdev = 24.756/24.931/25.060/0.229 ms [root@local tmp]# nmap 106.14.27.54 -p 22 Starting Nmap 5.51 ( http://nmap.org ) at 2019-03-29 11:57 CST Nmap scan report for 106.14.27.54 Host is up (0.025s latency). PORT STATE SERVICE 22/tcp open ssh Nmap done: 1 IP address (1 host up) scanned in 13.18 seconds [root@local tmp]# telnet 106.14.27.54 22 Trying 106.14.27.54... Connected to 106.14.27.54. Escape character is \'^]\'. Connection closed by foreign host. [root@local tmp]# mtr -c 1 -n --report 106.14.27.54 HOST: local Loss% Snt Last Avg Best Wrst StDev 1. 192.168.0.1 0.0% 1 0.4 0.4 0.4 0.4 0.0 2. 10.80.192.1 0.0% 1 78.8 78.8 78.8 78.8 0.0 3. 61.148.163.101 0.0% 1 1.0 1.0 1.0 1.0 0.0 4. ??? 100.0 1 0.0 0.0 0.0 0.0 0.0 5. 124.65.194.165 0.0% 1 2.3 2.3 2.3 2.3 0.0 6. 219.158.8.242 0.0% 1 23.6 23.6 23.6 23.6 0.0 7. ??? 100.0 1 0.0 0.0 0.0 0.0 0.0 8. ??? 100.0 1 0.0 0.0 0.0 0.0 0.0 9. 140.206.108.138 0.0% 1 26.0 26.0 26.0 26.0 0.0 10. 116.251.88.138 0.0% 1 24.6 24.6 24.6 24.6 0.0 11. 116.251.117.129 0.0% 1 26.0 26.0 26.0 26.0 0.0 12. ??? 100.0 1 0.0 0.0 0.0 0.0 0.0 13. ??? 100.0 1 0.0 0.0 0.0 0.0 0.0 14. 106.14.27.54 0.0% 1 24.4 24.4 24.4 24.4 0.0 [root@local tmp]# traceroute 106.14.27.54 traceroute to 106.14.27.54 (106.14.27.54), 30 hops max, 60 byte packets 1 192.168.0.1 (192.168.0.1) 0.366 ms 0.410 ms 0.493 ms 2 10.80.192.1 (10.80.192.1) 2.758 ms 2.751 ms 2.767 ms 3 61.148.163.101 (61.148.163.101) 2.201 ms 2.575 ms * 4 * * * 5 * * * 6 * 219.158.7.230 (219.158.7.230) 25.465 ms 219.158.8.242 (219.158.8.242) 27.456 ms 7 139.226.225.150 (139.226.225.150) 29.288 ms 139.226.210.90 (139.226.210.90) 31.313 ms 139.226.225.158 (139.226.225.158) 23.847 ms 8 139.226.204.102 (139.226.204.102) 29.683 ms 139.226.204.118 (139.226.204.118) 26.512 ms 139.226.213.42 (139.226.213.42) 35.685 ms 9 140.206.108.74 (140.206.108.74) 29.325 ms 140.206.108.130 (140.206.108.130) 32.861 ms 140.206.111.18 (140.206.111.18) 32.841 ms 10 116.251.113.206 (116.251.113.206) 37.861 ms 116.251.113.214 (116.251.113.214) 39.891 ms 42.120.241.38 (42.120.241.38) 39.896 ms 11 106.11.75.230 (106.11.75.230) 39.622 ms 116.251.106.146 (116.251.106.146) 40.114 ms 106.11.75.98 (106.11.75.98) 31.965 ms 12 * * * 13 * * * 14 106.14.27.54 (106.14.27.54) 24.202 ms 24.106 ms 24.146 ms
### CMD追踪路由命令
[c:\~]$ tracert -d 106.14.27.54
通过最多 30 个跃点跟踪到 106.14.27.54 的路由
1 1 ms 1 ms 1 ms 192.168.8.1
2 * * * 请求超时。
3 * * * 请求超时。
4 61 ms 23 ms 135 ms 114.247.23.189
5 43 ms 32 ms 47 ms 221.219.202.217
6 66 ms 69 ms 32 ms 202.96.12.25
7 90 ms 71 ms 85 ms 219.158.8.242
8 * * * 请求超时。
9 * * 78 ms 139.226.213.110
10 87 ms 71 ms 59 ms 140.206.108.74
11 174 ms 46 ms 65 ms 42.120.241.38
12 80 ms 94 ms 71 ms 116.251.117.133
13 * * * 请求超时。
14 * * * 请求超时。
15 53 ms 57 ms 67 ms 106.14.27.54
跟踪完成。
看起来网络是通的, 但是telnet返回的不对呀. 正常一般会是这样的
[root@local tmp]# telnet 140.143.242.126 22 Trying 140.143.242.126... Connected to 140.143.242.126. Escape character is \'^]\'. SSH-2.0-OpenSSH_5.3 ### ^] telnet> quit Connection closed.
通过阿里云账号控制台连接到服务器是可以的. 检查配置是否有问题
1. 服务端日志获取
tailf /var/log/secure ### 远程连接点击后, 这个日志没有更新,啥也没有...
2. 查看日志报错
3. SSH 服务会对相关密钥文件的权限进行检查。### 没发现异常
比如,私钥文件默认权限是 600,如果配置成 777 等其它权限,导致其它用户也有读取或修改权限。则 SSH 服务会认为该配置存在安全风险,进而导致客户端连接失败。
可以通过如下指令恢复相关文件的默认权限配置:
cd /etc/ssh/
chmod 600 ssh_host_*
chmod 644 *.pub
操作如下:
[root@centos]# cd /etc/ssh/
[root@centos]# chmod 600 ssh_host_*
[root@centos]# chmod 644 *.pub
[root@centos]# ll
total 156
-rw-------. 1 root root 125811 Nov 23 2013 moduli
-rw-r--r--. 1 root root 2047 Nov 23 2013 ssh_config
-rw------- 1 root root 3639 May 16 11:43 sshd_config
-rw------- 1 root root 668 May 20 23:31 ssh_host_dsa_key
-rw-r--r-- 1 root root 590 May 20 23:31 ssh_host_dsa_key.pub
-rw------- 1 root root 963 May 20 23:31 ssh_host_key
-rw-r--r-- 1 root root 627 May 20 23:31 ssh_host_key.pub
-rw------- 1 root root 1675 May 20 23:31 ssh_host_rsa_key
4. 用cat 等指令查看 /etc/hosts.allow 或 /etc/hosts.deny中是否包含类似如下配置:
all:all:deny
如果修改相关策略配置,建议提前进行文件备份。 ( 其实这一步还是没发现有问题 )
修改 /etc/hosts.allow 和 /etc/hosts.deny中的相关配置,或者整个删除或注释(在最开头添加 # 号)整行配置。比如:
# all:all:deny
最后试了下华为云的服务器也是连不上, 当时就想应该不是阿里云的原因. 总不能阿里华为都连接不上吧. 想想是网络的事吗? 试了下, 不用公司这个网络, 用无线网卡路由的网络Xshell和手机网络JuiceSSH软件试了下, 都可以连的上... 看来是公司网络问题了! 其实想想应该先试这一步检查的. 下次要注意.
附上阿里云问题处理参考链接:
https://help.aliyun.com/knowledge_detail/41470.html?spm=a2c4e.11153987.0.0.261b7f71uzTxrl
https://help.aliyun.com/knowledge_detail/40849.html?spm=5176.11065259.1996646101.searchclickresult.6a5c26d1WX1h8Z#h2-u8FDCu7A0Bu7EC8u7AEFu670Du52A1u914Du7F6Eu5F02u5E38u5BFCu81F44