Independent AI intelligence Two editions daily · ET
Fervor AI

Analysis · November 23, 2026 · concept

Bitwarden SSH agentClaude Code sandboxagent-securityclaude-codeprivacy

Your Coding Agent Can Read Your SSH Keys. Move Them Off Disk.

Claude Code's own docs say ~/.ssh is readable by default. Here's a short setup that puts your keys behind an approval prompt instead.

There is a folder on almost every developer's laptop that opens more doors than any password manager, and every coding agent you run can read it. It is ~/.ssh, and the private keys inside it log into servers, push to GitHub and sign commits without ever asking who is using them.

For years that was fine, because the only thing reading that folder was you. That stopped being true the day you let an agent run shell commands on your machine.

Claude Code's documentation is unusually blunt about it. Its sandbox (the feature that walls off what an agent's shell commands can touch) is off by default, and even when you turn it on, the default read scope is "most of the machine, including credential files such as ~/.ssh and ~/.aws/credentials," according to the sandboxing docs. The same page says, "There is no built-in credential deny list, so only the files and variables you list are restricted."

None of that is a scandal. It is how computers work. A program you run inherits your permissions, and a coding agent is a program that decides for itself which commands to run, sometimes after reading a README, an issue or a web page somebody else wrote.

The result: an SSH private key should no longer sit on your disk as a file anything can read. Keep it encrypted behind an agent that asks first, or on a hardware key if you want the stronger version.

This piece walks through why, and then through a setup you can do in an afternoon. The short version is three layers. Keys live in a vault and an SSH agent signs on request after you approve. A separate key signs your commits, so one stolen key is not enough. And your agent's own settings deny the folder as a backstop.

Why "the agent won't do that" isn't a plan

Think of a private key file like a house key taped under the doormat. The lock is excellent. The problem is that anyone who reaches the mat walks in, and they don't need to pick anything.

An SSH private key works the same way. Whoever can read the file can usually use it, unless it has a passphrase and they can't get that too. The server on the other end has no idea whether the request came from you at your desk or from a script that copied the file an hour ago.

So the question isn't whether your coding agent is trustworthy. It's how many things on your machine can read that file, and how many of them take instructions from text you didn't write. That list now includes the agent, every package install script it triggers, every MCP server (the plug-ins agents use to reach outside tools) you've connected, and anything a prompt injection talks the agent into running. Prompt injection is when instructions hidden in a web page, issue or email get treated by the model as if you had typed them.

Johanna Larsson's post from November 23 puts the motivation plainly. After "all the recent security vulnerability reports and company breaches," she moved her keys into Bitwarden and deleted the copies on disk, because on-disk keys are exposed to "malicious code scanning my disk." She doesn't single out AI agents. She doesn't need to. An agent with shell access is just another piece of code that can scan your disk.

The fix: let something else hold the key and ask you first

SSH already has the right idea built in. An SSH agent is a small background program that holds your keys and signs login requests on your behalf, so programs like ssh and git never touch the key file. Your operating system ships one. The catch is that the standard setup still loads the key from a file in ~/.ssh.

A vault-backed agent flips that. The key lives encrypted in your password manager, the agent exposes a local socket (a file-like address programs talk to), and every signing request goes through the vault app. You can make it prompt you before it signs.

Bitwarden's SSH agent is one version of this, built into its desktop app. Other password managers have their own versions, and macOS users can also keep keys in the Secure Enclave, which Larsson calls "incredibly cool" but skipped for convenience. The steps below use Bitwarden because its docs and Larsson's post give a complete, checkable path.

What changes in practice: when an agent, a script or you run git push, the vault asks for approval if you've set it to. A script that copies ~/.ssh finds nothing worth stealing, because the private key isn't there.

Put it into practice

Budget about half an hour, most of it spent making sure you don't lock yourself out of a server. Do one machine first.

1. Import your keys into the vault

In the Bitwarden desktop app, create an SSH key item and import your existing private key. Bitwarden accepts OpenSSH and PKCS#8 formats, not PuTTY keys, and can only generate new keys of the Ed25519 type, per its docs. Larsson calls the import screen "a bit awkward." It works.

2. Turn on the agent and the approval prompt

In the desktop app's settings, switch on Enable SSH agent. Then set Ask for authorization when using SSH agent. Bitwarden's setup page describes the setting and the Authorize prompt you'll see. Larsson uses the vault-lock option with a four-hour lock. If agents run on this machine, a prompt on each use is the safer pick, even though it is more clicking.

3. Point SSH at the new socket

The socket path depends on your OS and install. From Bitwarden's docs:

# macOS, .dmg install
export SSH_AUTH_SOCK=/Users/<user>/.bitwarden-ssh-agent.sock

# macOS, App Store install
export SSH_AUTH_SOCK=/Users/<user>/Library/Containers/com.bitwarden.desktop/Data/.bitwarden-ssh-agent.sock

# Linux
export SSH_AUTH_SOCK=/home/<user>/.bitwarden-ssh-agent.sock

Put the line in ~/.zshrc or ~/.bashrc. Larsson also adds it to ~/.ssh/config so every host uses it:

Host *
  IdentityAgent ~/.bitwarden-ssh-agent.sock

On Windows, Bitwarden says you must disable the built-in OpenSSH Authentication Agent service instead.

4. Test, then delete the files

ssh-add -L            # should list your keys from the vault
ssh -T git@github.com # Bitwarden should prompt you to authorize

Once a real login works from a fresh terminal, delete the private key files from ~/.ssh. Keep the vault backed up first. Bitwarden also notes your SSH client may fall back to the system agent without telling you and suggests keeping any local keys you still need somewhere other than ~/.ssh.

5. Use a second key just for signing commits

This is the part most guides skip, and it's the best idea in Larsson's post. Make a separate key whose only job is signing commits, so pushing signed code needs two keys, not one. Git supports SSH signing from version 2.34, per GitHub's docs, and Bitwarden's signing steps also list OpenSSH 8.8 or newer:

git config --global gpg.format ssh
git config --global user.signingkey "key::$(ssh-add -L | grep 'YOURKEYNAME')"
git config --global commit.gpgsign true
git config --global tag.gpgsign true
git cat-file -p HEAD   # check the signature is there

On GitHub, add that public key with the type Signing Key, separate from your authentication key. Then turn on a branch protection rule (a repository setting GitHub enforces on every push) that requires signed commits, because GitHub still accepts unsigned pushes unless you tell it not to.

6. Tell your agent the folder is off limits anyway

Defense in depth means assuming one layer fails. In Claude Code, deny rules stop the built-in file tools and common shell file commands from reading a path. A rule like Read(~/.ssh/**) in the deny list of settings.json covers the folder; the permissions docs explain the ~/ path form, and the settings docs show where deny rules go.

Those docs are honest about the limit. Deny rules cover tools like cat and head but "don't apply to a command that reads files without naming them," such as a Python script. For operating-system-level blocking, the sandboxing docs give this configuration:

{
  "sandbox": {
    "enabled": true,
    "credentials": {
      "files": [
        { "path": "~/.ssh", "mode": "deny" },
        { "path": "~/.aws/credentials", "mode": "deny" }
      ]
    }
  }
}

The same page notes the agent can retry a blocked command outside the sandbox unless you set "allowUnsandboxedCommands": false. Set it. Two more limits from those docs: the sandbox covers shell commands only (hooks and local MCP servers run outside it with your full access), and on native Windows commands run unsandboxed.

If you use a different agent, look up its equivalent. The principle carries over even where the setting names don't.

What you get, and what you don't

After this, a script that tars up your home folder gets public keys and config, not private keys. A git push triggered by an agent at 2 a.m. waits for you to click Authorize, if you chose the per-use prompt. A stolen authentication key can't produce a commit that shows as Verified, because signing needs the second key, and with the signed-commits rule on, GitHub rejects the unsigned push.

What you don't get is protection from yourself. If a prompt pops up while you're busy and you click Authorize without reading it, the agent pushed with your key. The prompt only helps if a surprise prompt makes you stop.

Honest limitations

The vault becomes the crown jewels. You've traded a key file for a vault. Use a strong master password and two-factor login, or you've moved the doormat, not removed it.

Bitwarden's agent has rough edges. It tries each key in your vault until one works, so many keys can cause failed logins on servers that cap attempts. Its docs suggest pinning IdentityFile per host as a workaround. You can't add or remove keys with ssh-add, and only Ed25519 keys can be generated in the app. All three are in About SSH.

Approval fatigue is real. Larsson's one complaint is that approving takes a click, not Touch ID. If you push forty times a day, you'll be tempted to loosen the prompt. Loosen it on machines where no agent runs, not on the ones where agents do.

This doesn't fix other secrets. Cloud credentials, .env files and tokens in environment variables are just as readable. Claude Code's docs say sandboxed commands inherit environment variables "including any secrets in its environment" unless you deny them. Apply the same thinking there.

Servers still trust the key. Moving the private key doesn't revoke copies that may have leaked before. If you've run untrusted code with keys on disk, rotate them.

The habit worth keeping

The old mental model was that your laptop had one user. The new one has a few: you, your agent, and whatever your agent reads. Keys on disk were designed for the first model.

Start with one machine tonight. Import one key, turn on the prompt, push one commit, and watch the approval pop up. If it feels like friction, that is the point. Then decide, deliberately, which machines deserve it.

Sources: Claude Code sandboxing docs, Claude Code permissions, Claude Code settings, Johanna Larsson, "You can't afford to keep your SSH keys on disk" (Nov 23, 2026), Bitwarden SSH agent setup, Bitwarden About SSH, GitHub commit signature verification. Docs read November 23, 2026.