Trying to SSH into server and getting key_load_public: No such file or directory error

  • I created a passwordless ssh connection to my remote server from my mac. It worked(!) and then I closed my terminal, re-opened it, tried again, and got the following (username, my_ip are not real):

    ssh -vvv [email protected]_ip
    OpenSSH_7.2p2, LibreSSL 2.4.1
    debug1: Reading configuration data /Users/Me/.ssh/config
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 20: Applying options for *
    debug1: /etc/ssh/ssh_config line 53: Applying options for *
    debug2: resolving "my_ip" port 22
    debug2: ssh_connect_direct: needpriv 0
    debug1: Connecting to my_ip [my_ip] port 22.
    debug1: Connection established.
    debug1: identity file /Users/Me/.ssh/id_rsa type 1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/Me/.ssh/id_rsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/Me/.ssh/id_dsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/Mes/.ssh/id_dsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/Me/.ssh/id_ecdsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/Me/.ssh/id_ecdsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/Me/.ssh/id_ed25519 type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/Me/.ssh/id_ed25519-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_7.2
    ssh_exchange_identification: read: Connection reset by peer
    

    When I checked my .ssh folder, id_rsa was there but none of the others were. From the error, it looks like I need to somehow create these files but am not sure how to do so.

    Any help would be appreciated.

    Is there an actual problem? For example, are you actually failing to log in? Could you [edit] your question to include the complete debug output, instead of just the first part?

    Yes; my apologies! I can't log in -- and I had left off the last (and perhaps most important?) line earlier.

  • Jakuje

    Jakuje Correct answer

    4 years ago
    debug1: key_load_public: No such file or directory
    

    The line above is not error, but just simple debug log saying that ssh client is not able to find separate public key (named ~/.ssh/id_rsa.pub). This file is not needed to connect to the remote server, but it can be useful.

    The actual error

    ssh_exchange_identification: read: Connection reset by peer
    

    points to error in server configuration. The server is running, but fails to accept the SSH connection. Check the server log for more information. Similar problems

    That link was very helpful. And, it turns out that I was in fact blacklisted (I had ssh'ed into my server too many times while I was testing something out.)

    My problem was a Bastion host had changed the IP address and the `known_hosts` was incorrect on my Mac... It showed `@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @`... It shows the line number by `~/.ssh/known_hosts:238`. So, I removed that line, 238 in this case, from the known_hosts file on my Mac and I tried to connect again successfully.

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM