dongwo2772 2017-08-10 19:07
浏览 565

Golang sFTP SSH:身份验证失败

For 3 days, I have been trying to set up a sFTP connection to upload a file to a client server.

I'm using this : https://gist.github.com/svett/b7f56afc966a6b6ac2fc

Only difference being that I added :

sshConfig := &ssh.ClientConfig{
    User: "0000003579",
    Auth: []ssh.AuthMethod{
        //SSHAgent(),
        PublicKeyFile("C:\\GoDev\\src\\Texel.ca\\Bnc_Ftp\\.ssh\\id_rsa"),
    },
    HostKeyCallback:   ssh.InsecureIgnoreHostKey(),
    HostKeyAlgorithms: []string{"ssh-dss"},
}
sshConfig.Ciphers = append(sshConfig.Ciphers, "aes128-cbc")

because my client server still use cbc and still use ssh-dss.

My issue :

When trying to connect, I get the following response:

Failed to dial: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

I tried to connect with the same credential via openSSH in a command line

ssh -oHostKeyAlgorithms=+ssh-dss ***@2XXX.XXX.XXX.XX -vvv

and it works.

Can I get more infos on my error like the -vvv command with openSSH? Or do any of you have an idea?

Thank you!

EDIT

Just for more information, there is a working tool right now that does the sftp transfert and it works.

But it's a .bat file that's why we are changing it to go.

It use WinSCP to connect to the sFTP with a rsa putty private key.

That might be one of the issue, as if I understand correctly, I can't use a puTTy private key with golang ssh package.

So I tried both the putty key and a conversion to openSSH, but both won't work.

  • 写回答

1条回答 默认 最新

  • dqlb38410 2017-08-11 07:07
    关注

    With openssh you're adding dss to the algorithms, and are using an unknown key. This key will be your default for the user and probably not the one you're using on the go side?

    On the Go side you're using only the dss Algorithm and an rsa key, which might be the problem?

    Make sure you're using the same key and same algorithms in both cases and that the algorithm matches the key.

    If still stuck perhaps post the full output of -vvv and all the errors on the go side.

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?