Skip to content

Instantly share code, notes, and snippets.

@evandertino
Forked from dmitshur/gist:6927554
Last active August 15, 2016 08:20
Show Gist options
  • Save evandertino/105daf54a319524975b45b9158b797d6 to your computer and use it in GitHub Desktop.
Save evandertino/105daf54a319524975b45b9158b797d6 to your computer and use it in GitHub Desktop.
How to `go get` private repos using SSH key auth instead of password auth.
$ ssh -A vm
$ git config --global url."git@github.com:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "git@github.com:"]
	insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!

Sources:

An alternative to using git@github.com is to generate a personal access token on your GitHub account, grant it repo access, and then use the following instead:

git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/"

That should still work with go get -u, and also works with Docker builds (my particular use case, and how I came across your gist).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment