brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ssh-add -l lists the keys your SSH agent has loaded

Network and access
~/tips/tip-ssh-add-list-loaded-keys

ssh-add -l

Shows the fingerprints of all keys held by the SSH agent, so you know what can log in for you.

An SSH agent keeps your unlocked keys in memory so you do not type the passphrase for every connection. It is handy, and it is good to know what it is holding.

ssh-add -l
ssh-add -L

The OpenSSH manual says -l lists the fingerprints of all identities currently represented by the agent, and -L lists the public key parameters instead. With a loaded key you see the key size, the fingerprint, the comment and the key type. If the agent is empty, you get a message saying the agent has no identities.

It is also the quick way to see which keys an agent would offer when something unexpected logs you in or fails to.

To remove keys again, the manual has two options. -d removes the given identities, or the default keys when you give no arguments. -D deletes all identities from the agent. Neither deletes the key files on disk, so you can add them again with ssh-add.

A time limit helps with a laptop you carry around: ssh-add -t 4h sets a maximum lifetime when adding a key.

The caveat is that the agent talks through a socket whose path is in SSH_AUTH_SOCK. If the variable is not set, ssh-add cannot reach an agent and says so. This happens in a fresh shell or a script that did not inherit the environment, and the keys are not lost.

Further reading: OpenBSD manual: ssh-add

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link