Git Repo with Custom SSH Key
Posted . ~1min read.
I love git. Love it.
I’ll save my love for Gitea for another day (TL;DR: Gitea is awesome).
Anyway, a lot of git repositories allow you to use ssh keys as authentication. This is a great thing, but of course, sometimes can be difficult to manage if lets say one repo for work uses one key and one that you use for a side project uses a different ssh key.
Here’s the simple way to do this…
In your local repo, run:
git config core.sshcommand 'ssh -i LOCATION/KEY'
example:
git config core.sshcommand 'ssh -i ~/.ssh/id_work`
That’s it. Now all your normal git pull
or git push
configs will use the specific key for just this repository.