Git With Ssh
Tags: git
Verbosity commands
Dos
set GIT_SSH_COMMAND=ssh -vvvgit clone ssh://bithucket/repoPowerShell
$env:GIT_SSH_COMMAND="ssh -vv"git clone ssh://bithucket/repoBash
GIT_SSH_COMMAND="ssh -vv" git clone ssh://bitbucket/repoMultiple keys per host
= this.source[0]
This is an issue if you have many keys with various permissions that are being used on one machine.
The previous answers have properly explained the way to create a configuration file to manage multiple ssh keys. I think, the important thing that also needs to be explained is the replacement of a host name with an alias name while cloning the repository.
Suppose, your company’s GitHub account’s username is abc1234. And suppose your personal GitHub account’s username is jack1234
And, suppose you have created two RSA keys, namely id_rsa_company and id_rsa_personal. So, your configuration file will look like below:
# Company accountHost companyHostName github.comPreferredAuthentications publickeyIdentityFile ~/.ssh/id_rsa_company
# Personal accountHost personalHostName github.comPreferredAuthentications publickeyIdentityFile ~/.ssh/id_rsa_personalNow, when you are cloning the repository (named demo) from the company’s GitHub account, the repository URL will be something like:
Repo URL: git@github.com:abc1234/demo.gitNow, while doing git clone, you should modify the above repository URL as:
git@company:abc1234/demo.gitNotice how github.com is now replaced with the alias “company” as we have defined in the configuration file.
Similary, you have to modify the clone URL of the repository in the personal account depending upon the alias provided in the configuration file.
- https://stackoverflow.com/a/38454037