src-d / go-git

Project has been moved to: https://github.com/go-git/go-git
https://github.com/go-git/go-git
Apache License 2.0
4.91k stars 541 forks source link

Respect ~/.ssh/config for host to key mapping #1220

Open swarupdonepudi opened 4 years ago

swarupdonepudi commented 4 years ago

It would be nice if go-git can use the config specified in ~/.ssh/config file to figure out the Auth part of the Clone operation. git already supports this.

Contents of ~/.ssh/config file

Host bitbucket.org
    HostName bitbucket.org
    User git
    IdentityFile ~/.ssh/bitbucket_key
Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/github_key
dontlaugh commented 4 years ago

Is there a reason this isn't implemented? E.g. would you accept a contribution that

My team encountered this on CI, where we needed to select a key to push with. CircleCI will automatically write an .ssh/config for the user running in the container, and drop the additional key into the .ssh folder, but go-git doesn't find it automatically.