How To Add Multiple SSH Keys

How To Add Multiple SSH Keys

How To Add Multiple SSH Keys

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

With the increase use of git-based version control systems like GitHub or GitLab, its quite evident that you may require multiple ssh keys to maintain different git repository for different accounts. In this blog post, we will discuss how to add multiple SSH keys in Windows or Linux system for multiple GitHub account.

The example given in this blog is with GitHub, but the same approach (with some minute changes) can be used for other providers like GitLab or Bitbucket etc.

Prerequisite:

  • Multiple GitHub account
  • Git installed in your local system

How To Add Multiple SSH Keys In Windows:

Step 1: Generate SSH keys for target systems

For this demo we will generate three keys, two for GitHub (for two separate account) and one for GitLab. This will give cover multiple providers, multiple account scenarios.

Note: It’s recommended to use key-phrase during ssh key generation.

Step 2: Add the public keys (.pub extension) to respective GitHub and GitLab accounts.

Login to GitHub with account A credentials and setup SSH keys.

How To Add Multiple SSH Keys

How To Add Multiple SSH Keys

Copy the content of $Home/.ssh/cloudaffaire_github.pub file and paste in the Key section below.

How To Add Multiple SSH Keys

Provide your GitHub password if prompted.

How To Add Multiple SSH Keys

Next, login to GitHub again with Account B credentials and repeat the same step to add the key.

Note: This time you have to copy the content of $Home/.ssh/debjeet_github.pub

Finally add the key for your GitLab account as well. You can follow step 2 and 3 below blog for same.

https://cloudaffaire.com/how-to-add-an-ssh-key-in-your-gitlab-profile/

Step 3: Create a ssh config file

Step 4: Add SSH private keys into the SSH authentication agent

Step 5: Finally, we reach the point to test if everything works

Note: You might get a warning as below, type yes

RSA key fingerprint is SHA256:ngfsdfsfd723hvhsdvbksghTxdCARLviKw6E5SY8.

This key is not known by any other names

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

How To Add Multiple SSH Keys In Linux:

Step 1: Same as step 1 for Windows.

Step 2: Same as step 2 for Windows.

Step 3: Create a ssh config file

Step 4: Add SSH private keys into the SSH authentication agent

Step 5: Finally, we reach the point to test if everything works

Note: You might get a warning as below, type yes

RSA key fingerprint is SHA256:nThbshdfy674vshdvjhsbdjgllasddsKw6E5SY8.

This key is not known by any other names

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Hope you have enjoyed this article.

Leave a Reply

Close Menu