Skip to content
BENIBIX Learn

ssh-agent

Infrastructure🔑 SSH & Remote AccessSSH Key Authentication

Also known as SSH Agent, ssh-add, SSH Key Agent

A helper that holds your keys open. You type the passphrase just once.

Think of it like

Think of it like a friend who holds your keys while you are out. You ask, and they open the door for you.

Example

Lucy logs in to servers twenty times a day. She adds her key to ssh-agent each morning and types the passphrase just once.

Why it matters

It makes a locked key as easy to use as an open one. So there is no need to skip the passphrase.

Definition

ssh-agent is a small program that holds your unlocked private keys in memory. You add a key with ssh-add and type its passphrase once. After that, ssh asks the agent to sign for you. You do not type the passphrase again until the agent stops. The keys never leave your own computer.

Example code

console
$ ssh-add ~/.ssh/id_ed25519
Enter passphrase for /home/lucy/.ssh/id_ed25519:
Identity added: /home/lucy/.ssh/id_ed25519 (lucy@laptop)
Type the passphrase once. The agent keeps the key open for the rest of the session.
ssh-agent sits beside the private key on the laptop. It signs each login so you do not retype the passphrase.

Common mistake

Turning on agent forwarding to servers you do not trust. Anyone with root there can use your agent while you are logged in.

Key takeaways

  1. 1
    Holds keys open. In memory, on your computer.
  2. 2
    Passphrase once. Then it signs for you.
  3. 3
    Careful forwarding. Only to servers you trust.

Learn it properly