DEV Community

Discussion on: How to use different SSH Keys for different Bitbucket (git) Repositories

Collapse
 
neerajpro profile image
Neeraj Goswami

Great article. There is an alternative to creating a SSH config file. Through your terminal you can tell any github repo to point to a particular ssh key file. just set sshcommand for that repo.

git -c core.sshCommand="ssh -i private_key_file" clone host:repo.git

git config core.sshCommand 'ssh -i private_key_file'

Collapse
 
bashar profile image
Bashar Al-Abdulhadi

you just made my day, thank you!

Collapse
 
shane profile image
Shane McGowan

Cool! Do you know if there is a way to choose your SSH Key for use with git clone when first cloning the repo?

Collapse
 
neerajpro profile image
Neeraj Goswami

yes it is git clone -c core.sshCommand="ssh -i ~/.ssh/your-ssh-fileName" git@github.com:orgname/repo.git