英文:
Failed to dial: handshake failed: ssh: no common algorithms Error in ssh client for golang
问题
我正在进行一个项目,使用 goftp 来上传到服务器,但是(多亏了这里的热心人),我将使用一种更安全的方法。
我计划改用 ssh,并在这里找到了一个在 golang 中的 ssh 客户端 here。
我已经设置了一个 ssh 服务器(freeSSHd),并且可以通过 PuTTY 在本地和另一台机器上成功连接。
我只更改了客户端的这部分,用自己的变量替换了原来的变量
var (
server = "127.0.0.1:22"
username = "username"
password = clientPassword("password")
)
当我执行 ssh 客户端时,ssh.Dial 返回一个错误,并且 panic 显示如下错误:
"Failed to dial: handshake failed: ssh: no common algorithms"
client, err := ssh.Dial("tcp", "127.0.0.1:22", config)
if err != nil {
panic("Failed to dial: " + err.Error())
}
我对 golang 还不熟悉,所以我会感激任何帮助,指导我朝正确的方向前进。提前感谢。
英文:
I'm working on a project that is using goftp to upload to a server, but (thanks to the kind people here) I will use a more secure method.
I plan to use ssh instead and found this ssh client in golang found here.
I have setup an ssh server (freeSSHd) and can successfully connect through PuTTY both locally and on another machine.
I have only changed this part of the client to replace the variables with my own
var (
server = "127.0.0.1:22"
username = "username"
password = clientPassword("password")
)
When I execute the ssh client, ssh.Dial returns an error, and the panic displays this:
"Failed to dial: handshake failed: ssh: no common algorithms"
client, err := ssh.Dial("tcp", "127.0.0.1:22", config)
if err != nil {
panic("Failed to dial: " + err.Error())
}
I am new to golang so I would appreciate any help to point me in the right direction. Thanks in advance.
答案1
得分: 8
在go.crypto/ssh
包的source code中,我们可以看到支持的加密算法如下:
- aes128-ctr
- aes192-ctr
- aes256-ctr
- arcfour128
- arcfour256
而freeSSHd支持的加密算法有:
- aes128-cbc
- aes192-cbc
- aes256-cbc
- 3des-cbc
- blowfish-cbc
- rijndael128-cbc
- rijndael192-cbc
- rijndael256-cbc
- rijndael-cbc@lysator.liu.se
由于客户端和服务器没有共同的加密算法,你会收到错误消息。ssh包不支持CBC模式的原因很可能是因为一个vulnerability,在golang-nuts讨论中有提到。
解决你的问题的一个方法可能是尝试安装不同的SSH服务器,比如OpenSSH for Windows。
英文:
In the source code for the go.crypto/ssh
package, we can see that the supported ciphers are the following:
- aes128-ctr
- aes192-ctr
- aes256-ctr
- arcfour128
- arcfour256
While freeSSHd supports:
- aes128-cbc
- aes192-cbc
- aes256-cbc
- 3des-cbc
- blowfish-cbc
- rijndael128-cbc
- rijndael192-cbc
- rijndael256-cbc
- rijndael-cbc@lysator.liu.se
Because the client and server shares no common cipher, you will get the error message. The reason why CBC mode is not supported in the ssh package is most likely because of a vulnerability, as discussed in this golang-nuts thread.
A solution to your problem might be to try install a different SSH server, such as OpenSSH for Windows.
答案2
得分: 2
尽管它不安全,但你可以使用Go语言的库来使用一个由freeSSH支持的密码算法。
sshConfig.Config.Ciphers = append(sshConfig.Config.Ciphers, "aes128-cbc")
英文:
Though it is insecure you can get go's library to use a cypher supported by freeSSH.
sshConfig.Config.Ciphers = append(sshConfig.Config.Ciphers, "aes128-cbc")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论