How does SSH know which key to use?

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 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?

2 Answers

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.

There is an option called "IdentityFile"...

I suggest reading a little bit about ssh.config. It is worth it. You can configure the key, port, user name...

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like