Trying to connect to an SSH server on one machine and it works fine. Not on the other

9,065

I figured out the issue. OSX was using it's own keychain and not the one in .ssh like a normal BSD or Linux system.

I just needed to add the id_rsa file to the keychain and then recopy.

The private key worked fine after that.

Got the info from here: http://fplanque.com/dev/mac/secure-ssh-private-keys-on-mac-osx-10-5

Share:
9,065

Related videos on Youtube

sobirds
Author by

sobirds

Updated on September 18, 2022

Comments

  • sobirds
    sobirds almost 2 years
    ~$ ssh -v [email protected]
    OpenSSH_6.9p1, LibreSSL 2.1.7
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 21: Applying options for *
    debug1: /etc/ssh/ssh_config line 25: Applying options for *
    debug1: Connecting to 45.79.8.241 [45.79.8.241] port 22.
    debug1: Connection established.
    debug1: identity file /Users/raina/.ssh/id_rsa type 1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/raina/.ssh/id_rsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/raina/.ssh/id_dsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/raina/.ssh/id_dsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/raina/.ssh/id_ecdsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/raina/.ssh/id_ecdsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/raina/.ssh/id_ed25519 type -1
    debug1: identity file /Users/raina/.ssh/id_ed25519 type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/raina/.ssh/id_ed25519-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_6.9
    debug1: Remote protocol version 2.0, remote software version OpenSSH_7.1p1-hpn14v9
    debug1: match: OpenSSH_7.1p1-hpn14v9 pat OpenSSH* compat 0x04000000
    debug1: Authenticating to 45.79.8.241:22 as 'raina'
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: server->client [email protected] <implicit> none
    debug1: kex: client->server [email protected] <implicit> none
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug1: Server host key: ssh-ed25519 SHA256:LQ1K6AddhnCMm3KVYX46yS9RZFcM8szWf+tpuCgtb/E
    debug1: Host '45.79.8.241' is known and matches the ED25519 host key.
    debug1: Found key in /Users/raina/.ssh/known_hosts:1
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: Roaming not allowed by server
    debug1: SSH2_MSG_SERVICE_REQUEST sent
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey
    debug1: Next authentication method: publickey
    debug1: Offering RSA public key:
    debug1: Server accepts key: pkalg ssh-rsa blen 535
    debug1: Authentication succeeded (publickey).
    Authenticated to 45.79.8.241 ([45.79.8.241]:22).
    debug1: channel 0: new [client-session]
    debug1: Requesting [email protected]
    debug1: Entering interactive session.
    debug1: client_input_global_request: rtype [email protected] want_reply 0
    debug1: Sending environment.
    debug1: Sending env LANG = en_US.UTF-8
    

    Other machine:

    $ ssh -v [email protected]
    OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
    debug1: Connecting to 45.79.8.241 [45.79.8.241] port 22.
    debug1: Connection established.
    debug1: identity file /home/Administrator/.ssh/id_rsa type 1
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/Administrator/.ssh/id_rsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/Administrator/.ssh/id_dsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/Administrator/.ssh/id_dsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/Administrator/.ssh/id_ecdsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/Administrator/.ssh/id_ecdsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/Administrator/.ssh/id_ed25519 type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/Administrator/.ssh/id_ed25519-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_7.1
    debug1: Remote protocol version 2.0, remote software version OpenSSH_7.1p1-hpn14v9
    debug1: match: OpenSSH_7.1p1-hpn14v9 pat OpenSSH* compat 0x04000000
    debug1: Authenticating to 45.79.8.241:22 as 'raina'
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: server->client [email protected] <implicit> none
    debug1: kex: client->server [email protected] <implicit> none
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug1: Server host key: ssh-ed25519 SHA256:LQ1K6AddhnCMm3KVYX46yS9RZFcM8szWf+tpuCgtb/E
    debug1: Host '45.79.8.241' is known and matches the ED25519 host key.
    debug1: Found key in /home/Administrator/.ssh/known_hosts:1
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: SSH2_MSG_NEWKEYS received
    debug1: Roaming not allowed by server
    debug1: SSH2_MSG_SERVICE_REQUEST sent
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey
    debug1: Next authentication method: publickey
    debug1: Offering RSA public key: /home/Administrator/.ssh/id_rsa
    debug1: Authentications that can continue: publickey
    debug1: Trying private key: /home/Administrator/.ssh/id_dsa
    debug1: Trying private key: /home/Administrator/.ssh/id_ecdsa
    debug1: Trying private key: /home/Administrator/.ssh/id_ed25519
    debug1: No more authentication methods to try.
    Permission denied (publickey).
    

    What gives? Same id_rsa in both

    • jordanm
      jordanm over 8 years
      What does the authorized_keys entry look like on the remote node?
    • sobirds
      sobirds over 8 years
      please help....
    • sobirds
      sobirds over 8 years
    • jordanm
      jordanm over 8 years
      What about ssh-add -l on the working host?
    • sobirds
      sobirds over 8 years
      what command is that?
    • sobirds
      sobirds over 8 years
      4096 SHA256:Nub+UPUpo5xrcrO4CcOfesacA8GAqf4Sh+L3PWJvhcY (RSA) on the mac
    • sobirds
      sobirds over 8 years
      Could not open a connection to your authentication agent.
    • sobirds
      sobirds over 8 years
      on the other box
    • jordanm
      jordanm over 8 years
      Your MAC used the SSH key in the ssh-agent keyring, which was likely not the same as ~/.ssh/id_rsa. You are using different keys on each system.
    • sobirds
      sobirds over 8 years
      How can I force it to use the one in .ssh
    • jordanm
      jordanm over 8 years
      ssh -i ~/.ssh/id_rsa, but that's just going to cause it to fail in both places, instead of just the second box. Just add ~/.ssh/id_rsa.pub on the second box to the authorized_keys file on the remote node.
    • sobirds
      sobirds over 8 years
      No way. There was definitely an easier way to make this work. Your telling me I need to change the authorized_keys file for every single box I want to connect to now? That can't be right.
    • sobirds
      sobirds over 8 years
      I used to be able to just copy the private key to any computer I wanted to use to connect to this box.
    • sobirds
      sobirds over 8 years
      figured it out. just need to add the .id_rsa file to the keyring and then copy-id again. then the private key works from any device.