diff --git a/main.go b/main.go
index 978e942b59e5c3e59b71988da7c58070003e2cad..d0fd7b9ce3abd9eb5a4807419e63721153c5463e 100644
--- a/main.go
+++ b/main.go
@@ -91,7 +91,7 @@ var RootCmd = &cobra.Command{
 			// Parse the pem key
 			privateKey, err = ssh.ParseRawPrivateKey(key)
 			if err != nil {
-				if err.Error() != "ssh: no key found" {
+				if _, ok := err.(*ssh.PassphraseMissingError); ok {
 					// If the key is encrypted, decrypt it
 					pass, err := getKeyPass(quiet)
 					if err != nil {