2013-09-25 07:11
浏览 216


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 = ""
    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", "", 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.

图片转代码服务由CSDN问答提供 功能建议

我正在使用 goftp 上传到服务器,但是(由于这里的友善),我将使用更安全的方法。



我仅更改了此部分 客户端用我自己的变量替换变量

密码= clientPassword(  “ password”)

当我执行ssh客户端时,ssh.Dial返回一个错误,并且恐慌显示如下: 拨号失败:握手失败:ssh:没有通用算法”

  client,err:= ssh.Dial(“ tcp”,“  “,config)
if err!= nil {
 panic(”拨号失败:“ + err.Error())

我是 是golang的新手,因此如果能为我指明正确的方向,我将不胜感激。 预先感谢。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongsha2792 2013-09-25 10:20

    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

    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.

    点赞 打赏 评论
  • dongzhou1901 2016-04-21 08:25

    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")
    点赞 打赏 评论

相关推荐 更多相似问题