196 points · by shintoist · 1d ago · 126 comments
The problem here is that everything is running as your user, so it's all the same security sphere.
You may be thinking, "But Bitwarden requires me to approve each key request". Problem is that if the attacker is already running as your user, which I'm assuming here because to steal your bare keys, they'd already need to be. This means they can also hit the approve button for you.
Ok, now you say "But it requires touchID!". Maybe that gets you just a little bit of protection, but...
The next idea is to just steal the decrypted key out of RAM. This requires a little bit of effort, because you generally can't attach to a sibling process without root on Linux with default configs. This will only delay things slightly. Attaching to your child is allowed, so all an attacker needs to do is replace your launch shortcut/service for Bitwarden with a thin wrapper that makes the attacker the parent process, and then they can just ptrace it and steal the decrypted key next startup. On Mac, where the ptrace path isn't viable due to disallowing ptrace of signed binaries by default, you could just replicate the Bitwarden GUI as a wrapper and steal the master password at startup.
If you really want to protect your keys from attacks like this, you need a real hardware device with OOB signaling.
Even things that will not stand up to a motivated attacker still add value towards reducing the likelihood of a breach, by increasing friction for attackers that are simply grabbing at low-hanging fruit. A setup with a bit more friction is a locked door in a long hallway of unlocked doors. Yeah someone can get through it, but it's not going to be their highest priority. This is the case for almost anything security related: layers of imperfect protection are good in combination.
If they are motivated then this advice doesn't really buy you much. If they aren't motivated then the advice is moot to begin with. Passphrase-protected keys on disk are perfectly adequate for defending against simple credential stealers.
Is this argument "if I move the keys from $HOME/.ssh to $HOME/ssh, the script kiddies may not have guessed and therefore I am secure" ?
Reminds me of that nodejs tech talk by the founder who wanted to do a new language or framework that restricted packages more securely so a bad one in node modules cant do as much harm
> This means they can also hit the approve button for you. . . . Ok, now you say "But it requires touchID!". Maybe that gets you just a little bit of protection, but...
That's a pretty big leap. Systems like Mac OS are designed so that other apps can't easily click that Touch ID button for you. The vast majority of attackers are going to be filtered at this step. Beyond that, anything that "clicks that button for you" could only work when you're logged in - another hurdle - and will probably result in some visible screen activity even if it's "clicked" quickly.
When compared to simple plaintext SSH keys stored on disk, it's a night and day difference.
This is like saying "sure, you could wear a seatbelt, but it's not going to do anything for you if you drive your car off a cliff, so why wear it at all?"
You’re not wrong, but for most of us the threat of a simple credential stealer is a million times more likely than being targeted by a dedicated, intelligent hacker.
In the most common compromise scenario, the attack comes along with some widely distributed software and is going for quantity of keys compromised via automated scripts, not precision extraction of one person’s keys through interactive exploration of their computer.
Adjust your security model if you’re in an important position at a big company or some other high value target.
For most of us, though, anything that defeats a common credential stealer is highly valuable.
It is certainly possible to enable authentication methods whereby two processes at the same privilege level cannot grab each other's secrets or tokens. Credential guard is one example, I am sure there are analogous implementations on Linux but I believe namespacing and SELinux attack this from different angles.
The next idea is to just steal the decrypted key out of RAM.
It is also not a given that a userland process can do this.Which is, in fact a relatively common posture.
[0] I also use an SSH key in Bitwarden for lower priority concerns, but my main SSH keys that get automatically installed on remote systems and used for signing commits are stored via FIDO on Yubis.
I moved all my security keys to keychains and use basic shell scripts to auth on every use. That helps a lot. On Linux this password protection can be different for every key.
I will consider what you wrote about regarding ssh keys, but what do you mean about "real hardware with OOB signaling"? <insert meme about rooted crypto wallet hardware>
I think Fedora permits it. Ubuntu blocks. No idea what are the defaults elsewhere, but it is not universal.
kernel.yama.ptrace_scope=2Supply chain risks are big nowadays.
That part of Touch ID would stop them.
Security postures are not binary. There’s a wide range of techniques to defeat some likely risks.
see also https://m.xkcd.com/1200/ (2013)
By having it as a GPG key, you get signing and encryption on top of SSH. You can pair it with gopass as a password vault.
I haven't had to make a new key for years, they're very hard-wearing, mine lives on my key ring with my house keys. But I wrote this script to automate setting up a new key, I haven't tested it with recent Yubikeys or a recent version of GPG, but might be a useful starting point: https://github.com/Method-B-Ltd/auto-gpg-card - PRs welcome if it's broken.
You still need to be really careful about what can run as your user, but being able to take the key away physically remove a load of risk.
There's very little hassle involved anyway. You set up the hardware key once and it lasts years and you have to configure SSH and GPG on any machines that you use as a terminal (not any of the machines you connect to). It is easily scripted and deployed en masse.
I'm talking about the hassle of entering your PIN everytime you need to use it. The idea of ssh keys is that you don't have to enter your password anymore, but if you just have to enter a different password everytime then I don't really see the point. If you still need to enter a PIN it also prevents automation, like having a backup run during the night to an offsite location via ssh.
- Good ergonomics
- No private key sitting unencrypted on disk
Hell, isn't it even the default when using `ssh-keygen`? As in, it prompts you for a passphrase if you don't explicitly tell it not to?
Yes but you can just hit <enter>
There's no need to reveal your unencrypted keys to Bitwarden or any other cloud service.
The default for keys added to ssh-agent without further config/options is to keep them unlocked indefinitely (as long as the ssh-agent process keeps running anyway).
I use yubikey Fido keys so I need to touch the key to unlock it
It’s quite wild to be working and see my yubikey flash waiting for input because I have an agent running a task and it’s trying things like GitHub auth without asking me. Not hard to imagine it taking the next step and just grabbing tokens it needs to do whatever it needs to complete its task
I can tell you at my work, a large enterprise, people have pretty much just given Claude auto-mode free rein to do everything. Incidents in production are honestly people just sharing the output of their Claude’s investigations colored by whatever skills, memory and tokens available to it
And it couldn't even do anything on github because the only token it can use (which is in the config file outside of its reach) can only do a very limited number of things on the repo.
I feel like a lot can be done without relying on the mechanism you use.
If you're running an LLM with access to your system, you've already thrown security and system stability out the window. That is an extremely foolish thing to do.
If you grant an LLM agent full system access, it’ll have full system access.
> First – Isn’t using a passphrase enough? Probably. I don’t intend to imply that this post is the only way that anyone should be doing SSH keys. [...] So yes, the ’traditional’ method is probably fine for most threat models.
https://blog.infected.systems/posts/2026-11-03-i-deleted-all...
Agents like Bitwarden and 1Password are more granular in their authorisation, in 1Password’s case I tap the fingerprint reader on my laptop when a process in a specific terminal first requests SSH key access to authorise that, after which it can use it as much as it likes until the session times out. Doing so however doesn’t mean that some other process spawned by some malware can also use it, that’s going to pop a prompt up again.
And any combination of things in-between - it all depends only on you imagination (or paranoia:) )
The downside is that you can only use it on the infra you control, i.e. GitHub will never trust ssh CA your are using for cert signing. But speaking of git forges, at least self-hosted forgejo supports ssh certs natively.
See: flotte.sh
He was right! As soon as a procedure is awkward or even looks like it might not work the first time I will deem it to be wrong.
Wrong because I don't want to learn another way and I don't need to learn another way than what is supposed to be the obvious way and if that is not immediately obvious to the user (customer) then I'm not going for it.
Useful as a recoverable hardware wallet probably not your daily driver but a long term/offline master.
It has the added benefit of having a screen so depending on what's needed you can see what key is accessed or what's being signed.
AI companies know this is true. All of their sandboxes must traverse a SSL Bump proxy that decrypts and logs everything the sandbox does. I had AI build a web interface that lets the AI see for itself that it is being observed.
[1] - https://ping.ohftp.org/Do-Not-Trust-Continuously-Verify.html
SSH keys are pretty much solved, I’m using 1Password’s SSH agent similar to what OP is doing with Bitwarden. It works wonderfully.
Various API keys are a pain in the backside. 1Password has some features which kind of maybe help by allowing you to keep credentials in 1Password and then exposing them either as a named pipe that requires auth to read, or via CLI wrappers that inject the credentials at runtime. Both of those still require long lived credentials though.
At some point I’ll probably snap and build something analogous to what 1Password are doing but using OAuth or similar to request short lived, scoped, credentials as needed. I assume there’s approximately six hundred things like this which are targeted at agent use but I’d like something that doesn’t require me to run everything in a sandbox.
That said, I don't understand how a dev like bigballs from DOGE managed to push an exfil tool up to a public GitHub repo. Even private repos leak info; wrote this tool to check up on friends and myself and was surprised to see private repo info pop up:
#!/bin/sh # gets recent GitHub activity for user. user="${1:-your-username-here}" outfile="/tmp/hist-for.log"
gh api --paginate "/users/$user/events" --jq '.[] | "\(.created_at) | \(.type) in \(.repo.name)"' | tee "$outfile"
echo "History for $user saved to $outfile."
exit 0
But one interesting centralized implementation I saw was about having a separate ssh server which you connected to with a forwarded ssh agent, and after doing 2FA dance it injected the freshly signed temp cert into your forwarded agent.
SSH CA is built into the openssh server for a long time and there are multiple opensource management platforms. You can even sign use limitations into the key.
That's effective when possible, but it's not quite the correct level of permission. Separation of users usually involves disjoint working spaces/sets, and that defeats many typical 'assistant' roles. For example, "look through my e-mail for the past month and remind me if anybody needs something from me" is a very useful task for an assistant (LLM or human), but it necessarily involves access to one's own information -- even on a read-only basis.
IMO we're missing a robust task-level permission system, and this is difficult because a 'task' does not have a 1:1 mapping to a path, user, or application.
I'd love e-mail provider that provides api-key-like IMAP creds I can just generate and hand out to automation, with not only read/write scope but also per-path one.
There’s plenty of way to share specific information across boundaries and some are quite fairly simple to implement. No need to create another complex project for each task.
The tooling is all DIY however and most people aren't used to operating multi-user environments, nor do they have filesystem permissions set up correctly, nor do they have a good way of handling secrets management, development environment credentials, etc etc etc.
Essentially, I feel like there's a lot of hand waving going on. Are you operating in this style of environment already? Are you using Claude Code or similar operating as another user on your local machine?
I run mine on an isolated VM with an unprivileged user. It's a hassle, but I still get plenty of work done with these agents. They can't read my email, but I think I'm okay with that.
Bitwarden can act as SSH agent if you want to keep them all in password manager
You can enroll your ssh keys into a yubikey, and have it securely stored in the hardware until you plug it in to ssh.
If you want secure the key, generate one on YK directly and use it. The entire point of hardware key storage is for key itself to never touch anything else
feels wrong. Unnecessary uses of cat.
`pbcopy < ~/.ssh/id_rsa`
`<~/.ssh/id_rsa pbcopy`
cat /a/thing
ok it looks right, let's continue cat /a/thing | thing doer
HN: "noooo you're doing it wrooong, use my obscure syntaaax that reads baaadlyy"^-a Meta-d
thing doer /a/thing
(mostly snark I am a fan of unnecessary cats)
If I put in a YubiKey in Windows, I should be able to use it in WSL, and when I SSH into another machine.
I run ssh-agent in Windows, and then have a socket-activated systemd service that uses the above program to forward the SSH agent socket to the Windows ssh-agent. I have a similar setup for my GPG agent. This lets me seamlessly use my Yubikey for SSH/GPG in both Windows and WSL.
You could also use something like usbip to expose the Yubikey to your WSL distro as a USB device, but this has to be done manually each time you want to use it, and you can't use it in Windows until you manually switch it back.
working on SIEM now (for beta4, now testing against fluentd, logstash, splunk, rsyslog)
is this a view of recent attacks everywhere? is this everyone just handling the keys to remote-chatbots with exec permission? is that just illiteracy?
i think that's the best angle of this discussion.
(also, extra funny they are worried about keys on disc stolen by local priviledged attakers, but use an ssh agent)
https://github.com/roddhjav/apparmor.d
(I'm the contributor)
Still, validation without extraction (FIDO2), instead of read to validate is the best solution in OP's situation.