Tech AI Insights

How to Set Up Multiple SSH Keys on One System

Managing multiple GitHub accounts or working with different repositories often requires more than one SSH key. In this blog, you’ll learn how to set up and use multiple SSH keys on the same system.

Whether you’re switching between personal and work accounts or handling multiple projects, this guide will help you configure SSH properly and avoid common connection issues — all in a simple and beginner-friendly way.

Step 1: Check for Existing SSH Keys

Open your terminal and type:

ls -al ~/.ssh

ssh key

Now you’ll see a list of your SSH keys. If you’ve already set one up, it will appear here—either with the default name id_ed25519 or a custom name you provided during setup.

Step 2: Generate a New SSH Key

Run the following command in your terminal:

ssh-keygen -t ed25519 -C "your_email@example.com"

When you see the message “Enter a file in which to save the key (/home/you/.ssh/id_ed25519):”, don’t press Enter immediately — doing so will overwrite any existing SSH key. Instead, type a custom name ( in my case I set tech) if you’re creating multiple keys or any name you prefered. Then press Enter and set a passphrase( a password you can easily remember for this SSH key)

ssh

Step 3: Add Your Public Key to GitHub

now, copy your public key to the clipboard:

cat tech.pub

Copy the entire output (starts with ssh-ed25519 and ends with your email).

You now have two SSH keys on your system, but when you try to push code using the newly generated key, GitHub still shows the email from the old key. To fix this, you need to configure your SSH setup to switch between the keys properly.

Step 4: Switch Between Multiple SSH Keys

Setup the host and file inside the config, its manditory if you you multiple ssh in your stem and you need all of them.

1. Open or create the SSH config file:

nano ~/.ssh/config

2. Add entries for each key:

# Personal GitHub
Host github-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes

# Work GitHub
Host github-work
HostName github.com
User git
IdentityFile ~/.ssh/tech
IdentitiesOnly yes

Paste this code into your file, replacing the filename with your actual key file. In my case, I have two files: id_ed25519 and tech. Use whichever one applies to your setup.

3. Use the correct host when cloning or working with repos:

Instead of cloning like this:

git@github.com:username/repo.git

Clone like this for personal:

git@github-personal:username/repo.git

Or like this for work:

git@github-work:username/repo.git

That’s it!

Now Git knows which key to use based on the host name you define. No need to manually switch anything — it’s automatic based on your SSH config.

For more insightful tutorials, visit our Tech Blogs and explore the latest in Laravel, AI, and Vue.js development!

Scroll to Top