COOKIES! This blog uses cookies!
I am completely out of control of cookies here, otherwise I would have disabled them (it is controlled by the platform).
If you don't like cookies and being tracked please leave this blog immediately.

Tuesday, 28 October 2025

Using specific ssh keys for different repositories

 (for example work and personal)

Using the same ssh key usually would not work, because you're likely to use different emails for your work and personal accounts.

Internet is full of suggestions of configuring different host in ~/.ssh/config, which certainly would work, however I like the following more:

1. Generate a new SSH key

ssh-keygen -t ed25519 -C "your@email.com" -f ~/.ssh/id_ed25519_work

2. Configure your repo to use specific SSH key:

 git config --add --local core.sshCommand 'ssh -i <<path to your private ssh key>>' 

path to the private key could be  /Users/username/.ssh/id_ed25519_home 

No comments:

Post a Comment