fix: ssh error parsing order fix

Needed to check for non-error case before error case.
This commit is contained in:
Sylvia Crowe 2024-09-06 13:58:27 -07:00
parent a9533b0426
commit f07ac79b0b

View File

@ -111,10 +111,6 @@ func createPublicKeyCallback(connCtx context.Context, sshKeywords *SshKeywords,
}
unencryptedPrivateKey, err := ssh.ParseRawPrivateKey(privateKey)
if _, ok := err.(*ssh.PassphraseMissingError); !ok {
// skip this key and try with the next
return createDummySigner()
}
if err == nil {
signer, err := ssh.NewSignerFromKey(unencryptedPrivateKey)
if err == nil {
@ -126,6 +122,10 @@ func createPublicKeyCallback(connCtx context.Context, sshKeywords *SshKeywords,
return []ssh.Signer{signer}, err
}
}
if _, ok := err.(*ssh.PassphraseMissingError); !ok {
// skip this key and try with the next
return createDummySigner()
}
// batch mode deactivates user input
if sshKeywords.BatchMode {