Search code examples
linuxsshssh-keysopenssh

Why can I do ssh to my server using any private key?


I have Public key authentication enabled for connection to my server, after connecting to my server using my correct private key I can authenticate to my server using any private key file and it works.

I use -i option for specifying the private key: ssh -i /anything meliwex@server_ip

Even if the file doesn't exist I can still connect to my server. Connection

Is it possible that ssh caches the private key? If yes how can I remove that cache?


Solution

  • You could add -v to see which keys are really used.

    The -i option isn't exclusive, ssh is still able to use keys from a ssh-agent and also the default keys from .ssh/id_*

    Probably your key in .ssh/id_rsa isn't protected with a passphrase.
    Therefore ssh will use it silently and you can login.