Another of fast paced configurations, this one is focused on have more ssh keys for different projects. I'm using my personal computer for work, well this implies different git access and configurations.
We need to start creating the SSH keys twice:
ssh-keygen -t ed25519 -C "[email protected]"
When I run the command above I usually save like: id_ed25519_personal
and id_ed25519_work
. Now you can add to the configuration.
touch ~/.ssh/config
And with your favorite editor put something like:
Host github.com
Hostname github.com
User git
IdentityFile ~/.ssh/id_ed25519_personal
Host bitbucket.org
Hostname bitbucket.org
User git
IdentityFile ~/.ssh/id_ed25519_work
Since my company do not uses github, I just put the general hostname for that.
Now it's a nice trick. Usually I've a global config for my email, but at the companies git it should use the corporate one. So, edit your ~/.gitconfig
file, and add:
[includeIf "gitdir:~/Projects/work/**"]
path="~/.work.gitconfig"
Now, create the ~/.work.gitconfig
and put:
[user]
email = [email protected]
Now everything from your work should be on the work folder, and everything there it will also have the .work.gitconfig
.