Skip to content

SSH Tips: Multiple SSH Keys

SSH Tips #1

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 "your_email@example.com"

Note: substitute the email with your associated email with Github.

ATTENTION!!

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.

Generate SSH key

Few things here:

  1. I need to type the whole pathname to where I want to save it and make sure to name the keys differently.

  2. It is totally up to you to fill in the passphrase, but I’m choosing the empty passphrase.

Adding the SSH to ssh-agent

Adding SSH to ssh-agent
  1. Start the ssh-agent in the background: eval $(ssh-agent -s).

  2. Add the ssh to ssh-agent: ssh-add <your_ssh_file_location. e.g: ssh-add ./ssh/id_rsa_personal.

  3. Create or change the .ssh/config file 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 ;)