How to add multiple ssh keys for a single user

If you are using multiple email addresses for different services and each of them require you to enter a different public key, then you need to have a public key generated locally for each such email address.

The only catch is, the default one can live in the file called whereas the others have to live in a different file and your local ssh would need to know where to find this file.

The following steps also help resolve the error – “Fingerprint has already been taken” when you are adding an existing ssh key on your website

Lets say you registered with using [email protected] and with using [email protected]

# First lets generate our SSH key for
ssh-keygen -t rsa -C "[email protected]"
# Assume you saved the above generated key in the default file

# Now lets generate our SSH key for
# We will need to save the next key in a different file.

ssh-keygen -t rsa -C "[email protected]"
# Assume you saved this one in /home/username/.ssh/id_rsa.two

The next step is to configure SSH to look for your custom file name. Here’s how thats done.
Edit your ~/.ssh/config file and add en entry for your custom file name which is used by gitlab.

  User git
  IdentityFile ~/.ssh/id_rsa.two

And now you can easily use each SSH key for each such website.

Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *