Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

免密登录失败 #14

Open
figureout opened this issue Jul 30, 2020 · 1 comment
Open

免密登录失败 #14

figureout opened this issue Jul 30, 2020 · 1 comment

Comments

@figureout
Copy link
Contributor

figureout commented Jul 30, 2020

用了私钥登陆但是设置了私钥密码会有问题:
unable to connect: parse private key failed: ssh: cannot decode encrypted private keys

可以支持下带密码的秘钥登陆:
原文 https://stackoverflow.com/questions/42105432/how-to-use-an-encrypted-private-key-with-golang-ssh

import "golang.org/x/crypto/ssh"
With unencrypted key:

signer, err := ssh.ParsePrivateKey(key)
With encrypted key:

signer, err := ssh.ParsePrivateKeyWithPassphrase(key, []byte("password"))
Then:

config := &ssh.ClientConfig{
User: username,
Auth: []ssh.AuthMethod{
ssh.PublicKeys(signer),
},
}

@mylxsw
Copy link
Owner

mylxsw commented Jul 30, 2020

OK,非常感谢,已支持,版本 v0.1.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants