↓ Skip to main content
  1. Tech Blog: AI, Security, Infrastructure & Open Source/

SSH Keys Off Disk — What Your Agent Still Authorizes

·1584 words·8 mins
Osmond van Hemert
Author
Osmond van Hemert
Cybersecurity Landscape - This article is part of a series.
Part : This Article

Moving an SSH private key out of ~/.ssh is useful. Concluding that malicious code can no longer use your identity is a different proposition.

In her November 23 account of moving SSH keys into Bitwarden’s agent, Johanna Larsson describes a familiar halfway house: the password manager held backup copies, while the working private keys remained on disk and were loaded with ssh-add. She changed the working arrangement, not just the backup location.

That is a worthwhile prompt to review a developer workstation. It is not a new Bitwarden feature announcement, and it is not evidence that a password manager defeats a compromised host. The important distinction is between stealing a reusable private key and getting an available agent to authenticate on your behalf.

Two Threats That Look Similar From the Terminal
#

OpenSSH’s agent manual describes an agent as a program that holds private keys for public-key authentication. Clients communicate with it through a socket. The key can stay with the agent while the client obtains the operation needed to authenticate.

That separation is valuable, but access to the socket is itself a security boundary. The same manual warns that its Unix-domain socket, although restricted to the current user, can be abused by root or another process running as that user. This is why “the key was never exported” is not equivalent to “the account was never used.”

Think about three situations rather than one generic “key theft” event:

SituationWhat moving the working key into a vault-backed agent changesWhat still needs attention
A script scans ordinary files for private keysRemoving loose private-key copies reduces what that scan can collect directlyOld exports, backups and other credentials may remain
Untrusted code runs while an agent can approve operationsDirect file theft and agent-mediated use become different attack pathsAgent access, approval policy and the permissions of the remote identity
An attacker controls the workstationThe absence of a loose key is still a narrower exposure reductionThe vault process, user session and approval interaction cannot simply be assumed trustworthy

These are threat-model distinctions, not results from a Bitwarden penetration test. They also explain why the developer credential exposure discussed in the ChainDrop npm worm analysis deserves more than a search for files named id_rsa: the question is what authority untrusted code can reach.

A passphrase-protected private-key file is not equivalent to a plaintext private key, either. Do not describe every stolen file as immediately usable. But do not make disk encryption or a passphrase do the conceptual work of runtime authorization: protecting a stored copy and controlling an active session are different jobs.

An Approval Window Is an Authorization Decision
#

Larsson chose approval when the vault is locked, with a four-hour vault-lock interval, explicitly balancing friction and convenience. That is her reported configuration, not a default to copy or a recommended protection interval for every workstation.

For a migration review, I would ask more precise questions:

  • Does approval cover one operation, one client, one key, or a period of time?
  • What happens to that approval when the vault locks, the screen locks, or the laptop resumes?
  • Can a denied request be retried without a new meaningful decision?
  • Does the prompt identify enough context to distinguish an expected operation from a surprising one?

Start with the shortest practical approval scope for sensitive identities, then test whether it remains usable during real work. A prompt that trains people to approve reflexively is a weak operational outcome even if it looks strict in a settings screenshot.

OpenSSH itself offers confirmation and lifetime controls through ssh-add: -c requests confirmation before authentication use, and -t sets an identity lifetime. Those are OpenSSH controls, not a promise that a password-manager agent implements the same flags or semantics. Check the agent you actually deploy.

I could not independently retrieve Bitwarden’s official SSH-agent help during this review, so this article deliberately does not reproduce installation clicks, socket paths or claims about its current approval options. The practitioner account establishes what Larsson chose; it is not a substitute for checking your installed version’s documentation and behavior.

Check Which Agent Each Tool Actually Uses
#

A migration can appear successful while different applications use different agents. OpenSSH documents that IdentityAgent overrides SSH_AUTH_SOCK. Configuring one therefore does not establish what every command-line tool, editor or GUI application will contact.

For a Unix-like OpenSSH client, these are useful read-only diagnostics:

# Effective SSH client settings for a host alias; does not connect.
ssh -G work-git

# Public identities exposed by the agent selected through SSH_AUTH_SOCK.
ssh-add -L

The ssh-add manual is explicit that -L lists public key parameters. That output tells you which identities an agent represents; it does not prove that authentication, denial, locking or recovery works. Treat it as an inventory check, not the migration’s acceptance test.

For host-specific selection, an illustrative client configuration is:

# Use your real host and the PUBLIC key matching the agent-held key.
Host work-git
  HostName git.example.com
  User git
  IdentityFile ~/.ssh/work-git.pub
  IdentitiesOnly yes
  ForwardAgent no

This assumes the intended agent is already selected and reachable. OpenSSH’s IdentityFile documentation allows a public-key file to identify a corresponding private key held by the agent, even when that private key is not present locally. Keeping a .pub file is not the same as keeping a private-key copy.

IdentitiesOnly yes narrows what this SSH client offers. It is not an agent-side access policy that stops other code from requesting operations. Likewise, a host alias is client configuration, not a restriction encoded into the key.

Be especially deliberate about forwarding. The ForwardAgent warning states the distinction plainly: someone able to access the forwarded socket cannot obtain key material from the agent, but can perform operations that authenticate with its identities. Leave forwarding off unless the workflow needs it and you understand which remote systems receive access.

Separate Signing From Login Without Calling It Two-Factor
#

Larsson also uses a dedicated SSH key for Git signing. I like that separation because it makes the intended roles easier to explain, inventory and revoke.

Git supports SSH signatures through gpg.format and user.signingKey. For example, inside a repository, with a dedicated signing key available in the selected agent:

git config --local gpg.format ssh
git config --local user.signingkey ~/.ssh/work-signing.pub
git config --local commit.gpgsign true

This is a configuration illustration, not a live-tested vault integration. It deliberately selects a named public-key file instead of taking whichever identity happens to appear first in an agent listing. Signing and then verifying a disposable test commit belongs in the migration checks; local verification also needs an appropriate trust configuration, such as Git’s documented gpg.ssh.allowedSignersFile.

The forge has its own registration rules. GitHub distinguishes authentication and signing keys; using the same key for both requires uploading it twice. A separate signing identity should not also be granted login access merely because that is convenient.

Two keys in one unlocked vault are not two independent authentication factors. They can improve role separation without providing independent compromise resistance. A signed commit also does not establish that its code was reviewed or safe to execute.

Recover First, Remove Copies Second
#

The dangerous migration milestone is not enabling an agent. It is removing the last working route back into a system before testing the replacement.

I would use the following acceptance checklist:

  1. Map the identities. Record each public-key fingerprint, its purpose, authorized accounts and servers, and the place to revoke it. Keep authentication and signing roles explicit.
  2. Pilot one low-risk destination. Test a fresh authentication, a rejected approval and a locked vault. Test terminal and GUI workflows separately; include behavior after a restart or suspend.
  3. Rehearse recovery. From a known-clean second environment, demonstrate the documented recovery route or a separately protected emergency identity. Do not count an already-open SSH session as proof. Avoid making access to recovery instructions depend on the vault you are trying to recover.
  4. Verify signing separately. Create and verify a disposable test commit using the intended signing identity and forge registration. Successful login is not evidence that signing works, or vice versa.
  5. Remove unnecessary private-key copies only after those checks. Review temporary exports, clipboard history, synced folders and backup retention. Removing today’s file does not prove historical copies vanished. If a key may already have leaked, replace and revoke it rather than treating relocation as remediation.

Centralization also concentrates dependency on vault access. The LastPass vault-breach discussion is useful context for asking what happens when a credential store becomes unavailable or exposed—not evidence that every password manager has the same architecture or risk.

Finally, do not solve automation friction by exposing your entire personal agent to a build job. The identity-scoping principle in CI/CD pipeline security applies here too: an unattended task should receive a narrowly scoped machine identity, not inherit a developer’s collection of interactive credentials.

My Take
#

I would rather have a deliberate, vault-backed authorization workflow than a collection of forgotten private-key files. But the success criterion should be “less reusable secret exposure, with controlled use and tested recovery,” not “nothing sensitive remains on disk.”

The most revealing question is what happens after the first approval. If you cannot explain which operations remain available, for how long, and how to stop them, changing the key’s storage location has left the authorization review unfinished.

For a team rollout, I would make the lock, denial and recovery drills part of acceptance before removing working copies. That is a better investment than a dramatic deletion command: it tests the boundaries the team will actually rely on when something goes wrong.

Cybersecurity Landscape - This article is part of a series.
Part : This Article

Related