Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitUpKit ssh credentials callback does not handle username correctly if it is defined in ssh config #976

Open
prostolyubo opened this issue Feb 6, 2024 · 0 comments

Comments

@prostolyubo
Copy link
Contributor

prostolyubo commented Feb 6, 2024

As mentioned in #35 the GitUp displays ambiguous error messages when there is an error related to ssh credentials. There may be many causes as @andreyz pointed out:

          I think the diagnosis of this error is incorrect. ssh agent and up and running and keychain is unlocked. Gitup still refuses to do a remote push.

Originally posted by @andreyz in #35 (comment)

I managed to isolate at least one that allowed me to create a workaround for myself, however fixing the issue is beyond my current scope of skills.

I simply changed the origin url from: ssh://git-codecommit.amazonaws.com/myproject
to ssh://myusername@git-codecommit.amazonaws.com/myproject
And now magically I can interact with the remote.
The reason it worked in terminal is because the username is defined in my ssh config:

Host git-codecommit.*.amazonaws.com
  User myusername
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/mykey

Now here's what my investigation revealed:

  1. libgit2 detects there is no username and calls request_creds with GIT_CREDENTIAL_USERNAME as an auth method (Username-only authentication request, Used as a pre-authentication step if the underlying transport, (eg. SSH, with no username in its URL) does not know which username to use.)
  2. The process ends up calling the _CredentialsCallback method in GCRepository.m but it does not know how to handle GIT_CREDENTIAL_USERNAME as it only supports: GIT_CREDENTIAL_SSH_KEY and GIT_CREDENTIAL_USERPASS_PLAINTEXT so it immediatelly returns error -30: "A user-configured callback refused to act "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant