SSH client adding specified private key to the end of key list

I encounter a problem where even after specifying private key:

ssh -i ./path/to/key.pem

still getting Too many authentication failures

The key is confirmed to be correct because it’s working under other SSH client.

Turns out, when examined using ssh -vvv, default OpenSSH implementation under Ubuntu is adding the explicit command line key to the end of key list. It will first try all keys under ~/.ssh/

Before reaching the correct key, it failed with exceeded number of retries. Hope it helps anyone

Written on February 21, 2017