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 id_rsa.pub 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 websiteLets say you registered with github.com using examp[email protected] and with gitlab.com using [email protected]
The next step is to configure SSH to look for your custom file name. Here's how thats done. Edit your
# First lets generate our SSH key for github.com ssh-keygen -t rsa -C "[email protected]" # Assume you saved the above generated key in the default file id_rsa.pub # Now lets generate our SSH key for gitlab.com # 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
~/.ssh/configfile and add en entry for your custom file name which is used by gitlab.
And now you can easily use each SSH key for each such website.
Host gitlab.com HostName gitlab.com User git IdentityFile ~/.ssh/id_rsa.two