Multiple SSH key for different github/gitlab account

Gitlab Error “Fingerprint has already been taken” then adding an SSH key used by another user

How to fix

Create and upload key for personal account

sh-keygen -t rsa
# store into ~/.ssh/id_rsa_personal
eval $(ssh-agent) > /dev/null
ssh-add ~/.ssh/id_rsa &> /dev/null
ssh-add ~/.ssh/id_rsa_personal &> /dev/null

Set SSH host config rules

Host gitlab.personal.com
HostName gitlab.com
# User git # didn't seem to make a difference
IdentityFile ~/.ssh/gitlab
Host gitlab.com
HostName gitlab.com
# User git # didn't seem to make a difference
IdentityFile ~/.ssh/id_rsa
Host *
AddKeysToAgent yes
UseKeychain yes
# IdentityFile ~/.ssh/id_rsa # MUST BE DISABLED
UseKeychain yes
ServerAliveInterval 30
ServerAliveCountMax 2
git clone git@gitlab.personal.com:yourUsername/yourRepo.git

--

--

--

Software Engineer @ London [https://www.linkedin.com/in/elvisciotti]

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Frequently Asked Questions

How to use Git with a Media Temple Grid server

Migration to Ginkgo v2

Stripe vs GoCardless

Deep dive: Hacking the 8-bit AVR

Trailhead Badges Release 9 : September 21’

Salesforce Trailhead Badges September

IF YOUhttps://nytimes.one/if-you-pick-your-nose-you-should-probably-stop-now-this-is-how-dangerous-i

Reactive programming: principles, standards, implementation in Java

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Elvis Ciotti

Elvis Ciotti

Software Engineer @ London [https://www.linkedin.com/in/elvisciotti]

More from Medium

How to Test Your NGINX Configuration Before Screwing it Up

“connection closed by remote host” When Fetching Go/PHP Private Dependencies via SSH

Static Libraries vs Dynamic libraries