Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you and is it advisable to use the same ssh key for github and gitlab/gitbucket

Can you use the same ssh key for different version control hosting services?

And if you can, what are the pros and cons?

Scenario: I have ssh keys that I am using on my computer, can I and should I use the same ssh keys with gitlab/gitbucket on the same computer?

like image 894
YulePale Avatar asked May 24 '19 04:05

YulePale


People also ask

Can I use same SSH key for GitLab?

The problem with multiple GitLab accounts is that you can't use one SSH key on both of them. For example, you have a personal email address associated with one GitLab account, and business email with another.

Can I use the same SSH key for two GitHub accounts?

GitHub does not allow us to use the same SSH key in multiple accounts, so we'll have to create separate keys for each account. We can create SSH keys and add them to our SSH agent by following this guide from the GitHub Documentation.

Can I use both GitHub and GitLab?

Yes you can, you can share the same key between them both (ssh key) or create a new one per git server.

Can I use the same SSH key for GitLab and Bitbucket?

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. One important piece will be connecting to each separately with SSH.


1 Answers

No, it is not advisable: a private key should remain used for only one service, that way you can revoke/change it just for that service.

What you can do is set up a ~/.ssh/config file in which you can associate the right private key with the right host, as explained here.

like image 163
VonC Avatar answered Oct 20 '22 00:10

VonC