V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
mangwen
V2EX  ›  Go 编程语言

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

  •  
  •   mangwen · 2019-11-01 17:23:02 +08:00 · 6078 次点击
    这是一个创建于 1609 天前的主题,其中的信息可能已经有所发展或是发生改变。

    ssh: handshake failed: ssh: no common algorithm for key exchange; client offered: [[email protected] 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)
    

    }

    6 条回复    2019-12-11 10:03:34 +08:00
    leezii
        1
    leezii  
       2019-11-01 17:36:26 +08:00
    这不就是说算法不一致吗
    lc7029
        2
    lc7029  
       2019-11-01 17:40:16 +08:00
    你看看设备是不是用的 ssh1,而程序不支持 ssh1。
    有些较老的设备只支持 ssh1 且不支持 ssh2。
    heijiaotuan
        3
    heijiaotuan  
       2019-11-01 17:40:52 +08:00
    客户端支持的 ssh 算法也太少了吧
    reus
        4
    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
        5
    TOUJOURSER  
       2019-12-09 14:46:39 +08:00
    请问这个问题解决了吗
    mangwen
        6
    mangwen  
    OP
       2019-12-11 10:03:34 +08:00
    @TOUJOURSER 没有 就是算法不一致 ,包不支持,换 python 操作交换机了 。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5358 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:50 · PVG 13:50 · LAX 22:50 · JFK 01:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.