Don't keep your SSH keys on disk
Storing SSH private keys unencrypted on disk is increasingly seen as risky, especially as malware and locally running AI agents make it easier to exfiltrate long‑lived credentials. Commenters compare approaches such as passphrase-protected keys with ssh-agent, password managers acting as SSH agents, hardware tokens like YubiKeys and TPM/Secure Enclave storage, and short‑lived SSH certificates, debating how much real protection each adds against both “smash‑and‑grab” stealers and more sophisticated attackers. A recurring theme is defense in depth and least privilege: isolating agents under separate accounts, avoiding agent forwarding on untrusted hosts, and favoring hardware‑backed or time‑limited credentials over static secrets.
Threat models and SSH keys on disk
- Many argue that traditional SSH keys with passphrases are “probably fine” for most people, especially against simple credential stealers.
- Others want to avoid any long‑lived credentials on disk (SSH, GitHub, AWS, etc.), citing supply‑chain malware (e.g.,
curl | bash,npm install) that just grabs~/.sshand config dirs. - Some see anxiety over local attackers as inconsistent with simultaneously trusting SSH agents and other powerful tools.
Passphrases, agents, and password managers
- Standard SSH key encryption +
ssh-agentis seen by some as sufficient, but ergonomically painful if you type passphrases repeatedly. - Default agents tend to keep keys unlocked for the whole session, meaning any process under that user can silently use them.
- Password managers acting as SSH agents (Bitwarden, 1Password) are praised for per‑app or per‑terminal prompts, TouchID integration, and better granularity.
- Skeptics note that if malware already runs as your user, it can often approve prompts, steal passphrases, or swap in wrappers around the agent.
Hardware tokens and secure enclaves
- Strong support for YubiKeys/FIDO2, TPM, and Secure Enclave: keys never leave hardware; actions may require PIN + touch.
- Some use hardware as SSH CAs or sign short‑lived certs rather than provide direct keys.
- Others find hardware keys impractical or fragile to integrate (e.g., WSL, cross‑OS setups).
LLM / coding agents and local privilege
- Several comment that locally running LLM agents drastically change the threat model, since people often give them broad permissions.
- Recommended countermeasures: separate user accounts, VMs, sandboxes, limited tokens, and strict logging/audit trails.
- Others observe that multi‑user setups and fine‑grained secret management are non‑trivial for typical developers.
Short‑lived credentials and SSH certificates
- SSH certificates and short‑lived, scoped credentials are repeatedly advocated: e.g., 10‑minute root on one host, 24‑hour unprivileged certs.
- This model is seen as the “grown‑up” approach at scale, but mostly feasible only on infra you control; public services like GitHub rarely accept your own SSH CAs.
Defense‑in‑depth vs. overkill
- Some emphasize that extra hurdles stop commodity stealers, even if they don’t block a dedicated attacker.
- Others worry that malware is quickly catching up to keyrings and password managers, so gains may be short‑lived.
- Usability concerns recur: overly complex setups push users back toward insecure shortcuts.