In my ssh_config
, I have configured SSH to use a specific key when connecting to a host. I want SSH to try only this key, not any other key it may find (in ssh agent or some other location), so I specified IdentitiesOnly
, too.
Host *.foobar.com
IdentityFile ~/.ssh/keys/id_ed25519
IdentitiesOnly yes
Now, the key is password-protected for better security. To avoid typing the password every time, I've added it to ssh-agent
(along with some other key):
$ ssh-add -l
256 SHA256:1seMMJNjoexbRqNlVDe9kxkWm8s7fKAEuo+dP+hYut0 (ED25519)
2048 SHA256:p5SXMJNjoexbRqNl8roRamdzz+HFVlRKxtQoEW3vLu0 (RSA)
However, when I try to connect, SSH keeps asking me for password to decrypt the key. Why? When I changed configuration to enforce using the other key from the agent, it worked.