The story goes like this. You have your GitLab for your personal projects as well as one for work. It seems all cool until you start working on both of them.
I personally like to have separate work and private stuff on my computer. 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. This is a great way to distinguish personal work from business, but it also comes with some challenges.
As I mentioned, you can’t have the same SSH key on GitLab accounts with different email address, so the good way to solve this is to create separate SSH keys for personal and for business projects. Even though it seems like a difficult task to solve, it’s pretty simple, once you understand the basics. So how can we solve this problem?
First thing is to create two SSH keys, which you can do with the following command in terminal, but be sure to name your keys however you want, until the name are not the same, because we will use it later in the process. I let default values for private SSH key, and I named business SSH key: work_rsa
ssh-keygen -t rsa -C "[email protected]"
You put your business and private email address for each of the keys. Now, if enter following command (which basically means, go to ~/.ssh folder and list all files)
cd ~/.ssh && ll
you can see that you have both of the keys with .pub extension and one without.
-rw------- 1 sasa staff 419B Jan 19 11:24 work_rsa -rw-r--r-- 1 sasa staff 106B Jan 19 11:24 work_rsa.pub
#github #ssh #terminal #gitlab