[easyssh] Modify AuthMethod order (appleboy/easyssh-proxy#38)

* Modify AuthMethod order to be sure that user configuration is first in the list because ss.Dial only try the first method

https://github.com/appleboy/drone-ssh/commit/2a8dbafca51
This commit is contained in:
SebastienDorgan 2017-11-23 14:37:01 +01:00 committed by Wataru Ashihara
parent 744da76e7c
commit 442ce52def
No known key found for this signature in database
GPG Key ID: CE9EC2D5AE43DEFA

View File

@ -74,12 +74,6 @@ func getSSHConfig(config DefaultConfig) *ssh.ClientConfig {
if config.Password != "" {
auths = append(auths, ssh.Password(config.Password))
}
if sshAgent, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK")); err == nil {
auths = append(auths, ssh.PublicKeysCallback(agent.NewClient(sshAgent).Signers))
defer sshAgent.Close()
}
if config.KeyPath != "" {
if pubkey, err := getKeyFile(config.KeyPath); err != nil {
log.Printf("getKeyFile: %v\n", err)
@ -96,6 +90,11 @@ func getSSHConfig(config DefaultConfig) *ssh.ClientConfig {
}
}
if sshAgent, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK")); err == nil {
auths = append(auths, ssh.PublicKeysCallback(agent.NewClient(sshAgent).Signers))
defer sshAgent.Close()
}
return &ssh.ClientConfig{
Timeout: config.Timeout,
User: config.User,