My SSH key revocation test quietly used another key
cleaning up after taking a server down, I found a deploy key nobody owned anymore: the one Gitea Actions used to ssh into my other box. Gitea was gone, the runner was gone, and the key was still in that box’s authorized_keys. it wasn’t on the cleanup list.
removed it from authorized_keys, then tested that it was actually rejected. the test appeared to show it still working.
why: IdentitiesOnly still reads ~/.ssh/config
the test used IdentitiesOnly=yes. something like this:
ssh -o IdentitiesOnly=yes -i ~/.ssh/old_key box
IdentitiesOnly=yes stops ssh from trying whatever the agent offers. it doesn’t stop it reading ~/.ssh/config. the man page says so: it uses the files “explicitly configured in the ssh_config files or passed on the ssh(1) command-line”. so ssh offers old_key, the server refuses it, and ssh quietly falls back to the IdentityFile from the matching Host box block, which works. the test looks like the revocation failed.
ssh -G shows it without connecting. with a throwaway config that has IdentityFile real_key under Host box (paths shortened):
$ ssh -F demo_config -G -o IdentitiesOnly=yes -i old_key box | grep ^identityfile
identityfile old_key
identityfile real_key
$ ssh -F none -G -o IdentitiesOnly=yes -i old_key box | grep ^identityfile
identityfile old_key
the test that actually tests the key
skip the config entirely:
ssh -F /dev/null -o IdentitiesOnly=yes -i ~/.ssh/old_key -p <port> user@host
-F none does the same thing and is the documented spelling. you lose the Host alias, so spell out the user, host and port.
after that the key was rejected.