golang ssh 包的时候思科设备可以 ssh 上去 华为不行 各位大佬指点一下

2019-11-01 17:23:02 +08:00
 mangwen

ssh: handshake failed: ssh: no common algorithm for key exchange; client offered: [curve25519-sha256@libssh.org ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521 diffie-hellman-group14-sha1], server offered: [diffie-hellman-group1-sha1 diffie-hellman-group-exchange-sha1] RunCommands result:

package main

import ( "fmt" "github.com/shenbowei/switch-ssh-go" )

func main() { user := "test" password := "QWX@123x" ipPort := "192.168.16.234:22"

//get the switch brand(vendor), include h3c,huawei and cisco
brand, err := ssh.GetSSHBrand(user, password, ipPort)
if err != nil {
    fmt.Println("GetSSHBrand err:\n", err.Error())
}
fmt.Println("Device brand is:\n", brand)

//run the cmds in the switch, and get the execution results
cmds := make([]string, 0)
cmds = append(cmds, "dis clock")
cmds = append(cmds, "dis vlan")
result, err := ssh.RunCommands(user, password, ipPort, cmds...)
if err != nil {
    fmt.Println("RunCommands err:\n", err.Error())
}
fmt.Println("RunCommands result:\n", result)

}

6145 次点击
所在节点    Go 编程语言
6 条回复
leezii
2019-11-01 17:36:26 +08:00
这不就是说算法不一致吗
lc7029
2019-11-01 17:40:16 +08:00
你看看设备是不是用的 ssh1,而程序不支持 ssh1。
有些较老的设备只支持 ssh1 且不支持 ssh2。
heijiaotuan
2019-11-01 17:40:52 +08:00
客户端支持的 ssh 算法也太少了吧
reus
2019-11-01 17:58:55 +08:00
搜索 "golang diffie-hellman-group1-sha1"
你会得到: https://github.com/golang/crypto/commit/36a967d3212260ed1abea70bb749e710e26457a

搜索 "golang diffie-hellman-group-exchange-sha1"
你会得到: https://github.com/golang/go/issues/17230

问搜索引擎显然比问 V2EX 好。
TOUJOURSER
2019-12-09 14:46:39 +08:00
请问这个问题解决了吗
mangwen
2019-12-11 10:03:34 +08:00
@TOUJOURSER 没有 就是算法不一致 ,包不支持,换 python 操作交换机了 。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/615345

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX