思科 SSH 断开连接

网络工程 思科 ssh
2021-07-25 10:16:38

我有一个带有 15.5(3)M 的 Cisco 867VAE,它与特定的合法 SSH 客户端断开连接 %SSH-4-SSH2 _UNEXPECTED_MSG: Unexpected message type

它在长凳上,不在服务中。我对 Cisco R1 的完全控制权对客户端的控制权不多。

R1 192.168.19.194/24
|
Client 192.168.19.1/24

我已经排除了看似常见的原因:

  • 在客户端缓存旧密钥(我在 R1 上重新生成,不是这个)
  • 远处的人试图闯入(肯定是我)

这还能是什么?我可以对路由器进行哪些更改以提供更多信息或避免出现问题?

我发现的唯一解决方法是在 R1 上启用 telnet,显然我不愿意这样做。

日志如下。

提前致谢

乔纳森

Cisco 是 867VAE,带有 C860VAE-ADVSECURITYK9-M),版本 15.5(3)M

R1#debug ip ssh 
Incoming SSH debugging is on

Oct 22 16:29:12.496: SSH0: starting SSH control process
Oct 22 16:29:12.496: SSH0: sent protocol version id SSH-1.99-Cisco-1.25
Oct 22 16:29:13.572: SSH0: protocol version id is - SSH-2.0-dropbear_2015.67
Oct 22 16:29:13.576: SSH2 0: Server certificate trustpoint not found. Skipping hostkey algo = x509v3-ssh-rsa
Oct 22 16:29:13.576: SSH2 0: kexinit sent: hostkey algo = ssh-rsa
Oct 22 16:29:13.576: SSH2 0: kexinit sent: encryption algo = aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
Oct 22 16:29:13.576: SSH2 0: kexinit sent: mac algo = hmac-sha1,hmac-sha1-96
Oct 22 16:29:13.576: SSH2 0: send:packet of  length 368 (length also includes padlen of 5)
Oct 22 16:29:13.576: SSH2 0: SSH2_MSG_KEXINIT sent
Oct 22 16:29:13.576: SSH2 0: input: total packet length of 336 bytes
Oct 22 16:29:13.576: SSH2 0: partial packet length(block size)8 bytes,needed 328 bytes,
               maclen 0
Oct 22 16:29:13.576: SSH2 0: input: padlength 8 bytes
Oct 22 16:29:13.576: SSH2 0: SSH2_MSG_KEXINIT received
Oct 22 16:29:13.576: SSH2 0: kex: client->server enc:aes128-ctr mac:hmac-sha1 
Oct 22 16:29:13.576: SSH2 0: kex: server->client enc:aes128-ctr mac:hmac-sha1 
Oct 22 16:29:13.576: SSH2 0: Using kex_algo = diffie-hellman-group14-sha1
Oct 22 16:29:13.768: SSH2 0: expecting SSH2_MSG_KEXDH_INIT
Oct 22 16:29:13.768: SSH2 0: input: total packet length of 272 bytes
Oct 22 16:29:13.768: SSH2 0: partial packet length(block size)8 bytes,needed 264 bytes,
               maclen 0
Oct 22 16:29:13.768: SSH2 0: input: padlength 5 bytes
Oct 22 16:29:13.768: SSH2 0: SSH2_MSG_KEXDH_INIT received
Oct 22 16:29:14.408: SSH2 0: signature length 271
Oct 22 16:29:14.408: SSH2 0: send:packet of  length 832 (length also includes padlen of 8)
Oct 22 16:29:14.408: SSH2: kex_derive_keys complete
Oct 22 16:29:14.408: SSH2 0: send:packet of  length 16 (length also includes padlen of 10)
Oct 22 16:29:14.408: SSH2 0: newkeys: mode 1
Oct 22 16:29:14.408: SSH2 0: SSH2_MSG_NEWKEYS sent
Oct 22 16:29:14.408: SSH2 0: waiting for SSH2_MSG_NEWKEYS
Oct 22 16:29:14.408: SSH2 0: ssh_receive: 272 bytes received 
Oct 22 16:29:14.408: SSH2 0: input: total packet length of 272 bytes
Oct 22 16:29:14.408: SSH2 0: partial packet length(block size)8 bytes,needed 264 bytes,
               maclen 0
Oct 22 16:29:14.408: SSH2 0: input: padlength 5 bytes
Oct 22 16:29:14.408: SSH2 0: send:packet of  length 80 (length also includes padlen of 15)
Oct 22 16:29:14.408: SSH2 0: computed MAC for sequence no.#3 type 1
Oct 22 16:29:14.408: %SSH-4-SSH2_UNEXPECTED_MSG: Unexpected message type has arrived. Terminating the connection from 192.168.19.1
Oct 22 16:29:14.512: SSH0: Session disconnected - error 0x00

编辑:附加配置。这是一个工作台配置,目的是为现场单位缩小这个问题的范围。

version 15.5
no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
aaa new-model
!
aaa authentication login default local
aaa authentication enable default enable
aaa authorization console
aaa authorization exec default local 
!
aaa session-id common
wan mode ethernet
!
ip domain name example.com
ip cef
no ipv6 cef
!
username root privilege 15 password 0 SECRET
!
controller VDSL 0
!
interface ATM0
 no ip address
 shutdown
 no atm ilmi-keepalive
!
interface Ethernet0
 no ip address
 shutdown
!
interface FastEthernet0
 no ip address
!
interface FastEthernet1
 no ip address
!
interface FastEthernet2
 no ip address
!
interface FastEthernet3
 switchport access vlan 1000
 no ip address
!
interface GigabitEthernet0
 no ip address
!
interface GigabitEthernet1
 no ip address
 shutdown
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
!
interface Vlan1000
 ip address 192.168.19.194 255.255.255.0
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
ip route 0.0.0.0 0.0.0.0 192.168.19.1
!
line con 0
 no modem enable
line aux 0
line vty 0 4
 privilege level 15
 transport input telnet ssh
!
scheduler allocate 60000 1000
!
end
1个回答

[编辑:底部更新]

原来这与加密算法有关,因此与 Cisco IOS 的版本有间接关系。

板凳上的路由器只是为了帮我调试问题。真正的问题是在全球遥测网络中安装了适量的 CPE 路由器。测试路由器的配置在 SSH 访问方面几乎相同,在接口方面略有不同。[编辑:当然,现场没有人接受 telnet,只能在工作台上帮助调试。]

[EDIT2] 经过进一步测试,区别在于双方协商的加密。

一项调查发现该客户端与 AES128-CBC 对抗,而与 AES128-CTR 对抗。

对一些可用路由器的调查显示,Cisco SSH 服务器在 15.2(4)M3、15.2(4)M6、15.3(2)T2、15.3(2)T、15.3(3)M 上使用默认配置;并以 15.4(3)M1、15.4(3)M3、15.5(3)M 失败。

我们正在使用 867VAE-K8 + 15.5(3)M,并且以下最小对配置更改使其失败/工作:

ip ssh server algorithm encryption aes128-ctr # FAILS
ip ssh server algorithm encryption aes128-cbc # WORKS

显然这是一个互操作性问题,并且客户端也可能存在问题。资源平衡强烈表明这是客户端错误而不是服务器错误,但奇怪的事情发生了。

可用的修复(删除那些不再合理的修复)

  • 使用远程登录
  • 降级到最高的,即 15.3(3)M
  • 配置 Ciscos 以使用aes128-cbc(或最好找到工作)
  • 更改/升级客户端(可能不可能)

突出的主要问题是如何让思科从 SSH 过程中提供诸如解密后数据包转储(监视器捕获似乎只能获取解密前信息)之类的任何内容。没有这个,我们所看到的只是思科的抱怨“对方发送了错误的东西”,这导致了供应商之间的相互指责而不是解决问题。

谢谢如果有人有更好的建议。

[编辑 2017-10-26] 案例昨天在 Cisco TAC 开庭,两个小时的电话开始有了进展。

  • 我编辑了上面的版本列表,因为我在切换点出错了。
  • 很明显,在 SSH 服务器发送 MSG_NEWKEYS 并等待 MSG_NEWKEYS 后,交换出错了
  • 在正常工作的系统上,SSH 服务器接收 MSG_NEWKEYS
  • 目前还不可能看到路由器在收到意外消息时认为它收到了什么
  • 从而无法看到它是否被错误地加密或错误地解密或其他问题

[EDIT2: 2017-10-29] 全程编辑以反映加密问题而不是其他任何问题。我们与客户作者保持密切联系,看看他们能找到什么。