Why can I still connect to my server when the keys I am using are clearly not accessible?
From my PC, to connect to the server:
ssh -l myLogin -i .ssh/key-file <SERVER_IP>
I have tried this in these 2 configurations :
- key-file doesn't exists on my PC, and key-file.pub doesn't exist on the server
- key-file doesn't exists on my PC, but key-file.pub content is in the
.ssh/authorized_keys
on the server
Both times, I get the following message, but I am still connected to the server:
Warning: Identity file .ssh/key-file not accessible: No such file or directory.
Note: I have already properly used this same PC to connect to the same server, using another proper key that I deleted locally
Is there a bad configuration on my server that allows connections without proper authentication? Or might there be any sort of cache on my PC that remembers how to access the server?
SSH in verbose
In verbose mode (when adding -v
), SSH gives more information:
Warning: Identity file .ssh/key-file not accessible: No such file or directory.
...
debug1: Will attempt key: localLogin@localLogin-laptop-ubuntu RSA SHA256:0DH/97OKekTIjdeuc2jO2Ixig9VVTpB7morVj2/GVJw agent
debug1: Will attempt key: localLogin@localLogin-laptop-ubuntu RSA SHA256:6l0joGtcoJv2yvia82zAtXK8PqBLQkesOOwDaCutc20 agent
debug1: Will attempt key: /home/localLogin/.ssh/id_rsa
debug1: Will attempt key: /home/localLogin/.ssh/id_dsa
debug1: Will attempt key: /home/localLogin/.ssh/id_ecdsa
debug1: Will attempt key: /home/localLogin/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/localLogin/.ssh/id_ed25519
debug1: Will attempt key: /home/localLogin/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/localLogin/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected]>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: localLogin@localLogin-laptop-ubuntu RSA SHA256:0DH/97OKekTIjdeuc2jO2Ixig9VVTpB7morVj2/GVJw agent
debug1: Server accepts key: localLogin@localLogin-laptop-ubuntu RSA SHA256:0DH/97OKekTIjdeuc2jO2Ixig9VVTpB7morVj2/GVJw agent
debug1: Authentication succeeded (publickey).
Authenticated to <SERVER_IP> ([<SERVER_IP>]:22).
...
As we can see, the Offering public key
mentions a key that I had just deleted from my local PC, but was still in ssh agent's cachge, and was still valid for the server. After logging out and on again to my local machine, everything went back to normal. Thanks @michael-hampton
localLogin-laptop-ubuntu
is the name of the only valid key that was on the server and correctly used in the past. But I removed it from my local.ssh
directory, and it still seems to be used as a fallback. Is that it?