1

This on a Pi 4 running Buster.

I'm trying to ssh into a web host (HostGator) from this Pi.

I know ssh is working on the host because I can ssh from a Mac to HostGator without a password using rsa key pairs:

MrMuscle:~ mnewman$ ssh mgnewman@[my host]
Last login: Sat Aug 22 17:47:47 2020 from 1.20.171.54
mgnewman@[my host] [~]#

I know SSH is working on the Pi because I can ssh into the Mac without a password:

pi@raspsky:~/.ssh $ ssh [email protected]
Last login: Sun Aug 23 06:11:14 2020 from 192.168.0.65.
MrMuscle:~ mnewman$

The host is in the known_hosts file:

pi@raspsky:~/.ssh $ ssh-keygen -F [my host]
# Host mgnewman.com found: line 1

This Pi's SD card was cloned from another Pi 4. On the new Pi I generated new public/private keys and new authorized_keys and known_hosts files.

Anyone have an idea as to how I can get this working?

tl;dr:

pi@raspsky:~/.ssh $ ssh mgnewman@[my host]
Connection closed by [my host IP] port 22

Here's what the debug output for the Pi looks like when the public key is sent to the host:

debug1: Offering public key: id_rsa RSA SHA256:4fUCtJQoMfxO/Za1goxtEjx5fyFq0tHgkus4jIhI7dE explicit
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
Connection closed by [myhost IP] port 22

Here's what the same lines look like from the debugging output on the Mac:

debug1: Offering public key: /Users/mnewman/.ssh/id_rsa RSA SHA256:2RluaUDGj/vNTMBi9DD1nEHT/Ets+qwbdvo+E7DsKS0
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: /Users/mnewman/.ssh/id_rsa RSA SHA256:2RluaUDGj/vNTMBi9DD1nEHT/Ets+qwbdvo+E7DsKS0
debug1: Authentication succeeded (publickey).
Authenticated to [myhost] ([my host IP]:22).
debug1: channel 0: new [client-session]

The entire verbose output:

pi@raspsky:~/.ssh $ ssh -vvv mgnewman@[my host]
OpenSSH_7.9p1 Raspbian-10+deb10u2, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "[my host]" port 22
debug2: ssh_connect_direct
debug1: Connecting to [my host] [[my host IP]] port 22.
debug1: Connection established.
debug1: identity file /home/pi/.ssh/id_rsa type 0
debug1: identity file /home/pi/.ssh/id_rsa-cert type -1
debug1: identity file /home/pi/.ssh/id_dsa type -1
debug1: identity file /home/pi/.ssh/id_dsa-cert type -1
debug1: identity file /home/pi/.ssh/id_ecdsa type -1
debug1: identity file /home/pi/[my host].ssh/id_ecdsa-cert type -1
debug1: identity file /home/pi/.ssh/id_ed25519 type -1
debug1: identity file /home/pi/.ssh/id_ed25519-cert type -1
debug1: identity file /home/pi/.ssh/id_xmss type -1
debug1: identity file /home/pi/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Raspbian-10+deb10u2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000002
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to [my host]:22 as 'mgnewman'
debug3: hostkeys_foreach: reading file "/home/pi/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/pi/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [my host]
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-```
debug2: host key algorithms: [email protected],[email protected],[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa,[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group-exchange-sha256
debug2: host key algorithms: ssh-rsa,ssh-dss
debug2: ciphers ctos: aes256-ctr,aes192-ctr,aes128-ctr
debug2: ciphers stoc: aes256-ctr,aes192-ctr,aes128-ctr
debug2: MACs ctos: hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,[email protected]
debug2: MACs stoc: hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,[email protected]
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug3: send packet: type 34
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug3: receive packet: type 31
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 4114/8192
debug3: send packet: type 32
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug3: receive packet: type 33
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:zvfdYBMDWtOFnGjLosCOjO9MNKNaLHVcYNJSg6Wx428
debug3: hostkeys_foreach: reading file "/home/pi/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/pi/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [my host]
debug3: hostkeys_foreach: reading file "/home/pi/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/pi/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys from [my host IP]
debug1: Host '[my host]' is known and matches the RSA host key.
debug1: Found key in /home/pi/.ssh/known_hosts:1
debug2: bits set: 4034/8192
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug1: Will attempt key: /home/pi/.ssh/id_rsa RSA SHA256:4fUCtJQoMfxO/Za1goxtEjx5fyFq0tHgkus4jIhI7dE
debug1: Will attempt key: /home/pi/.ssh/id_dsa
debug1: Will attempt key: /home/pi/.ssh/id_ecdsa
debug1: Will attempt key: /home/pi/.ssh/id_ed25519
debug1: Will attempt key: /home/pi/.ssh/id_xmss
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/pi/.ssh/id_rsa RSA SHA256:4fUCtJQoMfxO/Za1goxtEjx5fyFq0tHgkus4jIhI7dE
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
Connection closed by [my host IP] port 22
9
  • You did install the new public key on your web host, right? (Just asking to make sure – it looks vaguely like you run out of tries on the server after the first key. Which is an … interesting configuration on part of your hoster, but nothing we can do anything about.) Aug 23, 2020 at 6:40
  • Yep, it's there: ssh-rsa <snip> pi@raspsky
    – Buadhai
    Aug 23, 2020 at 8:31
  • And the bit you've redacted really matches your id_rsa.pub, or whatever key you're using for this connection, yes? Aug 23, 2020 at 9:00
  • 1
    Please run ssh with the "-vv" flag to print debugging output. Then edit your question to include the debugging output.
    – Kenster
    Aug 23, 2020 at 12:16
  • 1
    And you populated authorized_keys on the host with the new key you generated on the Pi? Aug 23, 2020 at 13:12

1 Answer 1

1

I'm really not sure what happened here. I never could get rsa to work so I thought I'd try ecdsa. I generated a key pair and copied the public ecdsa key to the authorized_keys file on the host. I tried to ssh with that and it worked:

pi@raspsky:~/.ssh $ ssh -i /home/pi/.ssh/id_ecdsa mgnewman@[myhost].com
Last login: Sun Aug 23 23:53:26 2020 from 1.20.171.54
mgnewman@[myhost].com [~]# exit

Then I tried rsa again. It also worked.

Did I somehow "fix" the authorized_keys file when I pasted the ecdsa key in? Maybe.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .