Why not just use the regular SSH agent with a password? Still encrypted on disk, so I don't see what the difference is.
I use tokens for my SSH (yubikey, token2). Private key never leaves the hardware. Requires both password and touch to unlock.
I’m currently trying to get to a point where I don’t keep long lived credentials on disk, and as much as possible keep them out of environment variables as well. I don’t want random processes running as my user account to be able to go sniff out my GitHub, AWS, and so on API tokens. Unfortunately It’s a massive pain to get right at the moment. I particularly don’t want long lived credentials where if a process sends them to a server somewhere they’re valid for ages afterwards.
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.
Everyone is updating their threat models to include locally operating LLM agents. Here's a random thought: Don't let LLM agents act on your local system as you? They should be operating in a constrained way with their own account and privileges, rather than acting directly on your behalf with your privileges and access. Treat the agent as if its another user.
cat ~/.ssh/id_rsa | pbcopy
feels wrong. Unnecessary uses of cat.
`pbcopy < ~/.ssh/id_rsa`
While in theory, this adds at least some small layer of protection, I have doubts that it adds anything meaningful to stop a smart attacker.
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.