Table of Contents

Multiple systemd SSH Agents


This works great on my Debian Bullseye / i3wm system. I don't see why this wouldn't work on other distros / DEs but YMMV.

Create a ssh-agent systemd service template


Administration

Manage the ssh-agent service

Naming the ssh-agent services


Set a default ssh-agent


Configure SSH to use the agent


Manage the keys in the ssh-agent

Configuring IdentityAgent and AddKeysToAgent in ~/.ssh/config will automatically add the key to the correct agent when you use it.


Gotchas


Example

After following the steps above, as an example I'll create a “default” agent for my everyday ssh keys and a “work” agent for my work ssh keys.

Create "Default" SSH Agent

Create "Work" Agent

Configuring IdentityAgent and AddKeysToAgent in ~/.ssh/config will add the key to the correct agent when you first use it.


Bonus Tip

For multi-user systems, make sure to add/configure files in /etc/skel so the agent dependencies are set up during user creation.


Conclusion

That's the general idea and should get your system set up with as many ssh-agents as you would ever want to create. Enjoy!