Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add SSH key for both github and bitbucket in single PC

Is it possible to use both the github and bitbucket repo in personal computer.

if not, Let me know any other possibilities.

Thanks in advance.

like image 431
kabeer rifaye Avatar asked Apr 19 '15 02:04

kabeer rifaye


People also ask

Can I use same SSH key for GitHub and Bitbucket?

Definitely YES. You can generate ssh key pair first, see How to generate, then go to . ssh directory, copy the content of id_rsa. pub, and paste into your github or bitbucket ssh setting area.

Can I have multiple SSH keys in my computer?

You use SSH for connecting to remote servers, which also includes managing your code using Git and syncing with remote repositories. Even though it is considered a good practice to have one private-public key pair per device, sometimes you need to use multiple keys and/or you have unorthodox key names.


1 Answers

Yes it is. You tell git where the remote code lives from a per-repository configuration file. You can even push to GitHub and Bitbucket from the same repository if you want to.

See here for more details: http://blog.lckymn.com/2013/03/11/git-push-to-pull-from-both-github-and-bitbucket/

One important piece will be connecting to each separately with SSH.

Your SSH keys should live in $HOME/.ssh and can contain any number of keys. The default name for an SSH key is id_rsa (or similar, depending on the protocol used to create it).

Try doing:

ls $HOME/.ssh

... to see what's in there.

I do what you are asking about myself and for me that brings up something like:

github-personal
github-personal.pub
bitbucket-work
bitbucket-work.pub
known_hosts

Where known_hosts is a file that contains a list of the servers I connect to and the public keys associated with them. The other files that end in .pub are my own public keys and the rest are my private keys.

You get your GitHub and Bitbucket keys into there by following their appropriate tutorials:

  • GitHub: https://help.github.com/articles/generating-ssh-keys/
  • Bitbucket: https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git
like image 115
Seth Holladay Avatar answered Nov 03 '22 09:11

Seth Holladay