From 835af1133481111523838c774f446c0173d99bca Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Fri, 17 Apr 2020 15:55:30 -0400 Subject: [PATCH] Fixed a bug in ssh login with encrypted private key Check the type of the returned error instead of the error message to determine if the private key file is encrypted by a passphrase. --- src/duplicacy_storage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/duplicacy_storage.go b/src/duplicacy_storage.go index 0035a48..8f0f115 100644 --- a/src/duplicacy_storage.go +++ b/src/duplicacy_storage.go @@ -349,7 +349,7 @@ func CreateStorage(preference Preference, resetPassword bool, threads int) (stor } else { keySigner, err = ssh.ParsePrivateKey(content) if err != nil { - if strings.Contains(err.Error(), "cannot decode encrypted private keys") { + if _, ok := err.(*ssh.PassphraseMissingError); ok { LOG_TRACE("SSH_PUBLICKEY", "The private key file is encrypted") passphrase = GetPassword(preference, "ssh_passphrase", "Enter the passphrase to decrypt the private key file:", false, resetPassword) if len(passphrase) == 0 {