TIL: SSH Tips #1 - Multiple SSH Keys
Did you know that you could generate many ssh keys on your machine? But, why do I need more than one ssh key?
I need many ssh keys for my personal and non-personal GitHub accounts. Well.. non-personal is anything that is not using my personal email account.
This is what I could do:
Generate SSH Key
Create the ssh key with the command:
$ ssh-keygen -t ed25519 -C "firstname.lastname@example.org"
Note: substitute the email with your associated email with GitHub.
Normally, I would keep pressing Enter to continue as the SSH key would store in the default file the prompt has assigned (id_rsa). However, since I need many SSH keys, I need to name the keys differently. This is to distinguish which one is which and also for later purposes.
Few things here:
I need to type the whole pathname to where I want to save it and make sure to name the keys differently.
It is totally up to you to fill in the passphrase, but I’m choosing the empty passphrase.
Adding the SSH to ssh-agent
Start the ssh-agent in the background:
eval $(ssh-agent -s).
Add the ssh to ssh-agent:
ssh-add <your_ssh_file_location. e.g:
Create or change the
.ssh/configfile and add this setup:
Host https://github.com <- change this to whatever git remote repository you're working on. PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa_personal <- change this to whatever you name your ssh-key.
If you have any comments or corrections please feel free to email them to me. Also, if you found any of the content on this website useful consider buy me a coffee ;)