Skip to content

Instantly share code, notes, and snippets.

@weatherbell
Last active August 9, 2018 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weatherbell/278c8a66b5a73b1cada25c84b8735455 to your computer and use it in GitHub Desktop.
Save weatherbell/278c8a66b5a73b1cada25c84b8735455 to your computer and use it in GitHub Desktop.
pip install a private github repository over SSH

Create a ~/.ssh/config file with contents like these:

Host myrepo
   HostName github.com
   User git
   PreferredAuthentications publickey
   IdentityFile /root/.ssh/my_repo_private_key

Then pip install like this:

pip install git+ssh://myrepo/my_github_account/myrepo.git
                            ^

Note the / instead of a : (as you would normally use when cloning a repo through ssh) as indicated by the caret above.

This is particularly advantageous when building a Docker image, as you do not have to wory about ssh-agent.

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