How does SSH know which key to use

ssh

I'm trying to set up ssh keys and I don't do this often. That said, I have 3-4 key pairs in my .ssh/ dir already. WHen I do ssh my_user@mydomain.com how does ssh know what key to use?

I don't want to have key per site, but rather use one private key for lots of sites, and put the public key on the remote server. Sometimes my username on the server is not the same as my local username (often). How does SSH know which key I want to use?

Best Answer

I also found the -v option while connecting and it shows what it's doing. Turns out, it tries a bunch of keys that it finds in the .ssh dir. Basically tries whatever's in there.

Related Question