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
  • Select an option

  • Save evandertino/105daf54a319524975b45b9158b797d6 to your computer and use it in GitHub Desktop.

Select an option

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."[email protected]:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "[email protected]:"]
	insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!

Sources:

An alternative to using [email protected] 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}:[email protected]/".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