Skip to content

Ask for SSH credentials again when passphrase is wrong - #4357

Merged
ethomson merged 1 commit into
libgit2:masterfrom
invenia:cv/ssh-passphrase-incorrect
Oct 28, 2017
Merged

Ask for SSH credentials again when passphrase is wrong#4357
ethomson merged 1 commit into
libgit2:masterfrom
invenia:cv/ssh-passphrase-incorrect

Conversation

@omus

@omus omus commented Sep 22, 2017

Copy link
Copy Markdown
Contributor

When trying to decode the private key it looks like LibSSH2 returns a LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED when the passphrase is incorrect. This change allows callback to be called again giving the user the chance to correct the passphrase or provide alternative credentials.

Additionally, switched the indentation from spaces to tabs which matches the surrounding code.

@ethomson

Copy link
Copy Markdown
Member

Interesting. I'm surprised it returns that, but this seems like a reasonable change when it does.

Would you mind wrapping that line? eg:

	if (rc == LIBSSH2_ERROR_PASSWORD_EXPIRED ||
	    rc == LIBSSH2_ERROR_AUTHENTICATION_FAILED ||
	    rc == LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED)
		return GIT_EAUTH;

@omus

omus commented Sep 29, 2017

Copy link
Copy Markdown
Contributor Author

Will do. I wasn’t sure what the libgit2 standard format was line wrapping.

@omus
omus force-pushed the cv/ssh-passphrase-incorrect branch from 9e2160d to d55636e Compare September 30, 2017 15:21
@omus

omus commented Sep 30, 2017

Copy link
Copy Markdown
Contributor Author

I wrapped the text. Note that since the code is indented with tabs it only looks aligned when using tabs which are 4 spaces.

@pks-t

pks-t commented Oct 6, 2017

Copy link
Copy Markdown
Member

I'm a bit surprised regarding your explanation. From libssh2_userauth_publickey_fromfile_ex(3):

       LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED - The username/public key combination was invalid.

From that, it seems like libssh2 has already been talking to the server here. In the end it doesn't matter, we should obviously return GIT_EAUTH for that case, as well.

@pks-t

pks-t commented Oct 6, 2017

Copy link
Copy Markdown
Member

One minor nit, after that it's good to go for me: it would be nice if the commit message's subject included the component the patch applies to. E.g. "transports: ssh: ask for credentials again when passphrase is wrong".

@omus

omus commented Oct 18, 2017

Copy link
Copy Markdown
Contributor Author

I can modify the commit message subject line. I'm guessing you don't care about commit message subject line length? I try to stick keep it to 50 characters.

@pks-t

pks-t commented Oct 20, 2017

Copy link
Copy Markdown
Member

We definitly care about the length, but 50 characters is just a little bit too strict in my opinion. I think something like 65 characters is much saner, especially with things like the component prefix.

When trying to decode the private key it looks like LibSSH2 returns a
LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED when the passphrase is incorrect.
@omus
omus force-pushed the cv/ssh-passphrase-incorrect branch from d55636e to f2f1472 Compare October 20, 2017 15:45
@omus

omus commented Oct 20, 2017

Copy link
Copy Markdown
Contributor Author

Update the commit message subject and additionally rebased the changes.

@omus

omus commented Oct 25, 2017

Copy link
Copy Markdown
Contributor Author

Bump

@ethomson

Copy link
Copy Markdown
Member

Awesome! Thanks for fixing this. ✨

@ethomson
ethomson merged commit 781d73b into libgit2:master Oct 28, 2017
@omus
omus deleted the cv/ssh-passphrase-incorrect branch October 28, 2017 15:59
@pks-t pks-t added the backport label Jan 11, 2018
@pks-t pks-t mentioned this pull request Jan 12, 2018
@pks-t pks-t removed the backport label Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants