Skip to main content

SSH Agent with Multiple Keys

Chapter 21: Managing Multiple SSH Identities

In this chapter, you'll learn how to manage multiple SSH identities, assign keys per host, and use IdentitiesOnly to eliminate authentication failures.

In the previous chapter, you learned what the SSH agent is, how to start it, add keys to it, and keep it running cleanly across terminal sessions.

You now have a workflow where you unlock your key once per session, and SSH handles authentication silently from that point on.

But most sysadmins and DevOps engineers do not have one server and one key. They have work servers, personal servers, GitHub, GitLab, a home lab, and a client's infrastructure - each with different keys, different usernames, and different connection requirements.

Without a proper system for managing this, SSH either uses the wrong key, tries too many keys and hits the server's authentication limit, or falls back to prompting you every time.

In this chapter, you will build that system using ~/.ssh/config and the SSH agent together to ensure SSH always uses the right key for the right destination, automatically.

Mastering Linux in 7 Days - The Ultimate Beginner’s eBook
A complete 7-day crash course to help beginners master Linux, the command line, software management, and more. No experience needed!

Managing Multiple SSH Identities Without Errors

Pro TecMint Β· Root Plan
This Article is for Root Members
Join Root to read the full article and unlock everything

Full Access to Every Article, Course & Certification Track

Join thousands of Linux professionals who use Pro TecMint to advance their careers.

Ad-free access to all premium articles
All courses: Learn Linux, Bash, Golang, Ubuntu and more
RHCSA, RHCE, LFCS & LFCA certification prep
New courses added every month
Private Telegram community & priority support
Root Plan
$8/mo
or $59/year billed annually
Save $37 with annual plan
Start Reading This Article in the Next 60 Seconds
Join Root Plan β†’