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
.