DEV Community

loading...

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
shane profile image
shane Author

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