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)
}
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.