-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make LibGit2 retry when SSH passphrase is wrong
According to the LibGit2 authentication guide (https://libgit2.github.com/docs/guides/authentication/) the callback is suppose to be retried if the server doesn't accept the credentials. In the case where we use SSH and the passphrase is invalid LibGit2 would just give a generic: GitError(Code:ERROR, Class:SSH, Failed to authenticate SSH session: Callback returned error)
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
commit eac62497aec204568a494743f829d922787d69c5 | ||
Author: Curtis Vogt <curtis.vogt@gmail.com> | ||
Date: Thu Sep 21 15:51:52 2017 -0500 | ||
|
||
Ask for credentials again when passphrase is wrong | ||
|
||
When trying to decode the private key it looks like LibSSH2 returns a | ||
LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED when the passphrase is incorrect. | ||
|
||
diff --git a/src/transports/ssh.c b/src/transports/ssh.c | ||
index 172ef413c..ec3b0b6ff 100644 | ||
--- a/src/transports/ssh.c | ||
+++ b/src/transports/ssh.c | ||
@@ -420,8 +420,8 @@ static int _git_ssh_authenticate_session( | ||
} | ||
} while (LIBSSH2_ERROR_EAGAIN == rc || LIBSSH2_ERROR_TIMEOUT == rc); | ||
|
||
- if (rc == LIBSSH2_ERROR_PASSWORD_EXPIRED || rc == LIBSSH2_ERROR_AUTHENTICATION_FAILED) | ||
- return GIT_EAUTH; | ||
+ if (rc == LIBSSH2_ERROR_PASSWORD_EXPIRED || rc == LIBSSH2_ERROR_AUTHENTICATION_FAILED || rc == LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED) | ||
+ return GIT_EAUTH; | ||
|
||
if (rc != LIBSSH2_ERROR_NONE) { | ||
if (!giterr_last()) |