From f07ac79b0b9f43fd6e5e02966844789db83f126e Mon Sep 17 00:00:00 2001 From: Sylvia Crowe Date: Fri, 6 Sep 2024 13:58:27 -0700 Subject: [PATCH] fix: ssh error parsing order fix Needed to check for non-error case before error case. --- pkg/remote/sshclient.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/remote/sshclient.go b/pkg/remote/sshclient.go index e8c4c0f06..a97b28f9d 100644 --- a/pkg/remote/sshclient.go +++ b/pkg/remote/sshclient.go @@ -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 {