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

ssh authenticate #1146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wiegelmann
Copy link

fixes #934 and #1023

Copy link
Owner

@MichaelMure MichaelMure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thank you for doing this.

A few things:

  • as we have seen with the recent XY backdoor, it's important for that kind of code to be cristal clear: could you comment in the body of those function about what you are doing and why?
  • is that a workaround for a go-git issue? If so, could you mark it clearly, ideally with a link to an upstream issue?

@wiegelmann
Copy link
Author

wiegelmann commented Apr 15, 2024

Hi, according to go-git/go-git#218 go-git does not load public keys from ~/.ssh, meaning you need an active ssh-agent running otherwise you will get errors like:

  • Linux: error creating SSH agent: "SSH agent requested but SSH_AUTH_SOCK not-specified"
  • Mac: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
  • Windows: error creating SSH agent: "SSH agent requested, but could not detect Pageant or Windows native SSH agent"

If the ssh-agent is running and contains valid keys, everything is fine. If the ssh-agent has invalid keys or is not running, we try to find public keys in ~/.ssh and retry fetch/push again.

Tested this PR on Linux, Mac with the following scenarios:

  • ssh-agent running with valid and invalid keys in ~/.ssh
  • ssh-agent not running with valid keys in ~/.ssh

On Windows fetch/pull fails with and without ssh-agent. With this PR it works with valid keys in ~/.ssh.

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.

0.8.0 issue with Authentication
2 participants