Worked smoothly on most systems.
Kind of messy on Windows, because there are so many SSH agent implementations, but GPG4Win's latest version works with the native SSH now. Real progress.
And that’s completely separate to the PIV functionality on the key.
Don’t forget this diagram of all the agents, protocols and bridges you might hit on Windows.
It should be a prime example of what NOT to do.
I tested it now in a minimal privilege account in a chroot on Debian 11 that I use for login from untrusted machines, and strace worked. This is how I captured a password entered into a ssh client password prompt, opened in another login shell of the same user:
-bash-5.1$ ps aux | grep abcde
z 2502130 0.0 0.3 9500 6132 ? S+ 18:04 0:00 ssh abcde@localhost
z 2502140 0.0 0.1 6316 2336 ? S+ 18:04 0:00 grep abcde
-bash-5.1$ strace -p 2502130
strace: Process 2502130 attached
read(4, "s", 1) = 1
read(4, "e", 1) = 1
read(4, "c", 1) = 1
read(4, "r", 1) = 1
read(4, "e", 1) = 1
read(4, "t", 1) = 1
read(4, "\n", 1) = 1
write(4, "\n", 1) = 1
ioctl(4, TCGETS, {B38400 opost isig icanon -echo ...}) = 0
Doesn't really protect you.
Sandboxing is pretty much the only way to solve this, SELinux does place restrictions but that's a dumpster fire of over engineering that's useless for the end user, who when they find their computer isn't doing what they want it to do, will turn it off.
QubesOS calls this "split ssh" and you can use the same pattern with pgp.
There's also this which I don't see mentioned much: https://manpages.debian.org/unstable/ssh-agent-filter/ssh-ag...
The program doesn’t even need to be malicious, for a while it was a pretty common attack vector to trick browsers into uploading random file you could access.
Later, a malicious ssh server could read memory of the ssh process, potentially exposing the private key (CVE-2016-0777)
Using an agent with an encrypted key protects against that. Using a yubikey/smartcard as well. So it’s strictly a good thing to use it.
A yubikey could potentially protect you against a malicious program that wants to open connections if you have set it up to confirm every key operation - but that comes at a cost. You could also use little snitch to see what network connections a program opens, protecting you against a program trying to use your agent to access a server.
You can have the best of both worlds by storing the key itself in a place that's not readable by many programs. TPMs and other such tech can store a key securely without risk of FunnyGame.app sending it to a remote server. In this model the key would be stored inside a safe, sandboxed place, only readable by an SSH agent or similar, which will prompt for permission to use the key every time. With fingerprint scanners and other biometrics being available even in cheap devices, this process can be relatively seamless.
If you run sufficiently modern SSH software, you can also use external key stores like Yubikeys to authenticate with plain old OpenSSH.