Minggu, 14 Februari 2016

ssh offering wrong keys

the problem

somehow ssh trying offering keys to server before fallback to password authentication. If you run ssh command with -v option, you can see more verbose message :
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: user@pc
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Offering RSA public key: user@pc
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Offering RSA public key: user@pc
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Offering RSA public key: user@pc
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Offering RSA public key: /home/user/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/user/.ssh/id_dsa
debug1: Trying private key: /home/user/.ssh/id_ecdsa
debug1: Trying private key: /home/user/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
Received disconnect from 192.168.0.1: 2: Too many authentication failures
Disconnected from 192.168.0.1

Solution

I found solution for this issue in stackoverflow post. Summary :
root cause for this issue is because by default ssh agent will search for keys on default path : ~/.ssh/id_dsa, ~/.ssh/id_rsa, ~/.ssh/id_ecdsa. You can ovveride this behavior by add this on ~/.ssh/config or /etc/ssh/ssh_config :
Host *
IdentitiesOnly yes

1 komentar: