Is it possible to use GitHub and GitLab on one machine?


I have accounts in GitHub and GitLab. I generated and added an RSA key to my account in GitLab, but now I need to work with GitHub on a second project.

I know that GitLab and GitHub both use git. Please tell me if it’s possible to use GitHub and GitLab on one machine?


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

Create a SSH config file

When you have multiple identity files(in your case one for gitlab and one for github) , create a SSH config file to store your various identities.

The format for the alias entries use in this example is:

Host alias 
  IdentityFile ~/.ssh/identity

To create a config file for two identities (workid and personalid), you would do the following:

Open a terminal window.
Edit the ~/.ssh/config file. 

If you don’t have a config file, create one.
Add an alias for each identity combination for example:

Host github
IdentityFile ~/.ssh/github

Host gitlab
IdentityFile ~/.ssh/gitlab

This way you can have as many accounts as you wish each one with a different ssh key attached to it.

Answered By – CodeWizard

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published