我使用此代码https://gist.github.com/svett/b7f56afc966a6b6ac2fc作为起点.
使用它并将其指向cisco路由器会收到以下错误消息:
拨号失败:ssh:握手失败:ssh:客户端到服务器密码没有通用算法; 客户提供:[aes128-ctr aes192-ctr aes256-ctr aes128-gcm@openssh.com arcfour256 arcfour128],服务器提供:[aes128-cbc 3des-cbc aes192-cbc aes256-cbc]
做了一些阅读后,我了解到我可以通过自定义配置来启用aes128-cbc:
// CBC mode is insecure and so is not included in the default config.
// (See http://www.isg.rhul.ac.uk/~kp/SandPfinal.pdf). If absolutely
// needed, it's possible to specify a custom Config to enable it.
Run Code Online (Sandbox Code Playgroud)
所以我补充说:
HostKeyAlgorithms: []string{"aes128cbcID"},
Run Code Online (Sandbox Code Playgroud)
到我的ssh.ClientConfig,我得到了一个不同的错误:
拨号失败:ssh:握手失败:ssh:主机密钥没有通用算法; 客户提供:[aes128cbcID],服务器提供:[ssh-rsa]
这基本上让我觉得我在指定客户端到服务器密码的时候指定了HostKeyAlgorithm,但我找不到足够的方法来弄清楚如何这样做.
有任何想法吗?
你想要的是Ciphers在客户端的配置中设置字段.它位于通用ssh.Config结构中,嵌入在ssh.ClientConfig
sshConfig.Ciphers = []string{"aes128-cbc"}
Run Code Online (Sandbox Code Playgroud)