in Git

Multiple SSH Keys settings for different gitlab account

Well, this is a problem i came across not exactly a problem but couldn’t follow any tutorial out there. When i wanted to setup two different gitlab account for my machine. I had already configured my first account and was working on with it.It had no problem but the same account for work and home made it quite messy .Messy ? Don’t get me wrong , i know we could group our projects but still i preferred two gitlab account one for my office work and another for my side projects. Now let’s get into the business.

Getting Started

First, let’s go to our terminal and enter :

ssh-keygen -t rsa -C “”

while, inputing the key file : the_full_path_to_ssh/id_rsa_example

the_full_path_to_ssh : my identity file should be saved in ssh so /Users/Wizard/.ssh this is my fullpath

Now we have created our identity file in /Users/Wizard/.ssh/id_rsa_example and public key goes on


cd ~/.ssh/

Now we’re on our ssh folder. If you have installed sublime or any other editor and have aliases made for them , you can use it. I have installed sublime with alias lime, which mean i could open up sublime with lime .

lime -a config

you can open up your config file going to the .ssh folder .

saving configuration for two different account.

Let’s save public keys to our different gitlab account. Go to add ssh keys and save our public keys there.If you’re following along with me.

The default public keys for first account will be in id_rsa_pub and second one will be in Open up these files and copy paste them in you gitlab account.

Lastly, let’s test them if it’s working:

ssh -T

ssh -T

Remember whenever you have to initialized your gitlab repos you have to do

git remote add origin

In ssh config file, we have created the different accounts have different host remember ? 🙂 happy coding 🙂

  • Related Content by Tag