How to discover where 'pip install git+ssh://...' is searching for ssh keys?

For deploying in projects with multiple ssh keys do following:

$ export GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key_1"
$ pip install git+ssh://git@<my_hosted_gitlab>/project_with_deploy_key_1
$ export GIT_SSH_COMMAND="ssh -i ~/.ssh/deploy_key_2"
$ pip install git+ssh://git@<my_hosted_gitlab>/project_with_deploy_key_2

It can be integrated in CI process.


The GIT_SSH_COMMAND environment variable enables overriding the command that Git uses to run ssh. In this case, you want to enable verbose output. On Windows this looks like:

set GIT_SSH_COMMAND=ssh -v

Then when you run pip install git+ssh://github.com/USER_NAME/REPO_NAME.git, ssh outputs debug information, including where it looks for keys:

...
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [192.30.253.112] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/MyName/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/MyName/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/MyName/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/MyName/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
...