[SOLVED] Ubuntu SSH ignoring RSA key

Server: Ubuntu 16.04 LTS.

Client: Ubuntu 14.04 (software not up to date, but can ssh to lots of other systems).

/var/log/auth.log on server:

Mar 4 01:06:52 ubuntu sshd[4113]: Connection closed by 72.192.241.249 port 44844 [preauth]

(above only after I hit ctrl-C out of ssh on the client while it was prompting for a password).

Output from ssh -vvv:

ssh -vvv root@$host id

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014

debug1: Reading configuration data /home/jack/.ssh/config

debug1: /home/jack/.ssh/config line 1: Applying options for *

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: /etc/ssh/ssh_config line 19: Applying options for *

debug2: ssh_connect: needpriv 0

debug1: Connecting to li572-161.members.linode.com [192.155.88.161] port 22.

debug1: Connection established.

debug3: Incorrect RSA1 identifier

debug3: Could not load "/home/jack/.ssh/id_rsa" as a RSA1 public key

debug1: identity file /home/jack/.ssh/id_rsa type 1

debug1: identity file /home/jack/.ssh/id_rsa-cert type -1

debug1: identity file /home/jack/.ssh/id_dsa type -1

debug1: identity file /home/jack/.ssh/id_dsa-cert type -1

debug1: identity file /home/jack/.ssh/id_ecdsa type -1

debug1: identity file /home/jack/.ssh/id_ecdsa-cert type -1

debug1: identity file /home/jack/.ssh/id_ed25519 type -1

debug1: identity file /home/jack/.ssh/id_ed25519-cert type -1

debug1: Enabling compatibility mode for protocol 2.0

debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.7

debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.1

debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH* compat 0x04000000

debug2: fd 3 setting O_NONBLOCK

debug3: loadhostkeys: loading entries for host "li572-161.members.linode.com" from file "/home/jack/.ssh/knownhosts"

debug3: loadhostkeys: found key type ECDSA in file /home/jack/.ssh/knownhosts:73

debug3: load_hostkeys: loaded 1 keys

debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521

debug1: SSH2MSGKEXINIT sent

debug1: SSH2MSGKEXINIT received

debug2: kexparsekexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

debug2: kexparsekexinit: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,ssh-ed25519,ssh-rsa,ssh-dss

debug2: kexparsekexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se

debug2: kexparsekexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se

debug2: kexparsekexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96

debug2: kexparsekexinit: hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96

debug2: kexparsekexinit: none,zlib@openssh.com,zlib

debug2: kexparsekexinit: none,zlib@openssh.com,zlib

debug2: kexparsekexinit:

debug2: kexparsekexinit:

debug2: kexparsekexinit: firstkexfollows 0

debug2: kexparsekexinit: reserved 0

debug2: kexparsekexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1

debug2: kexparsekexinit: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519

debug2: kexparsekexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com

debug2: kexparsekexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com

debug2: kexparsekexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1

debug2: kexparsekexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1

debug2: kexparsekexinit: none,zlib@openssh.com

debug2: kexparsekexinit: none,zlib@openssh.com

debug2: kexparsekexinit:

debug2: kexparsekexinit:

debug2: kexparsekexinit: firstkexfollows 0

debug2: kexparsekexinit: reserved 0

debug2: mac_setup: setup hmac-sha1-etm@openssh.com

debug1: kex: server->client aes128-ctr hmac-sha1-etm@openssh.com none

debug2: mac_setup: setup hmac-sha1-etm@openssh.com

debug1: kex: client->server aes128-ctr hmac-sha1-etm@openssh.com none

debug1: sending SSH2MSGKEXECDHINIT

debug1: expecting SSH2MSGKEXECDHREPLY

debug1: Server host key: ECDSA ca:d2:b4:7e:36:17:9e:42:8c:6c:6f:cd:a1:a8:f9:b1

debug3: loadhostkeys: loading entries for host "li572-161.members.linode.com" from file "/home/jack/.ssh/knownhosts"

debug3: loadhostkeys: found key type ECDSA in file /home/jack/.ssh/knownhosts:73

debug3: load_hostkeys: loaded 1 keys

debug3: loadhostkeys: loading entries for host "192.155.88.161" from file "/home/jack/.ssh/knownhosts"

debug3: loadhostkeys: found key type ECDSA in file /home/jack/.ssh/knownhosts:74

debug3: load_hostkeys: loaded 1 keys

debug1: Host 'li572-161.members.linode.com' is known and matches the ECDSA host key.

debug1: Found key in /home/jack/.ssh/known_hosts:73

debug1: sshecdsaverify: signature correct

debug2: kexderivekeys

debug2: set_newkeys: mode 1

debug1: SSH2MSGNEWKEYS sent

debug1: expecting SSH2MSGNEWKEYS

debug2: set_newkeys: mode 0

debug1: SSH2MSGNEWKEYS received

debug1: SSH2MSGSERVICE_REQUEST sent

debug2: service_accept: ssh-userauth

debug1: SSH2MSGSERVICE_ACCEPT received

debug2: key: /home/jack/.ssh/id_rsa (0x7f3a472476d0),

debug2: key: /home/jack/.ssh/id_dsa ((nil)),

debug2: key: /home/jack/.ssh/id_ecdsa ((nil)),

debug2: key: /home/jack/.ssh/id_ed25519 ((nil)),

debug1: Authentications that can continue: publickey,password

debug3: start over, passed a different list publickey,password

debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password

debug3: authmethod_lookup publickey

debug3: remaining preferred: keyboard-interactive,password

debug3: authmethodisenabled publickey

debug1: Next authentication method: publickey

debug1: Offering RSA public key: /home/jack/.ssh/id_rsa

debug3: sendpubkeytest

debug2: we sent a publickey packet, wait for reply

debug1: Authentications that can continue: publickey,password

debug1: Trying private key: /home/jack/.ssh/id_dsa

debug3: no such identity: /home/jack/.ssh/id_dsa: No such file or directory

debug1: Trying private key: /home/jack/.ssh/id_ecdsa

debug3: no such identity: /home/jack/.ssh/id_ecdsa: No such file or directory

debug1: Trying private key: /home/jack/.ssh/id_ed25519

debug3: no such identity: /home/jack/.ssh/id_ed25519: No such file or directory

debug2: we did not send a packet, disable method

debug3: authmethod_lookup password

debug3: remaining preferred: ,password

debug3: authmethodisenabled password

debug1: Next authentication method: password

root@li572-161.members.linode.com's password:

Permissions of .ssh on client:

drwx–---- 2 jack jack 4096 Mar 3 18:32 .

drwxr-xr-x 37 jack jack 4096 Mar 3 18:31 ..

-rw-r--r-- 1 jack jack 990 Nov 2 19:07 authorized_keys

-rw------- 1 jack jack 135 Aug 20 2015 config

-rw------- 1 jack jack 1675 Nov 2 19:06 id_rsa

-rw-r--r-- 1 jack jack 396 Nov 2 19:06 id_rsa.pub

-rw------- 1 jack jack 30264 Mar 3 18:18 known_hosts

-rw------- 1 jack jack 28050 Feb 28 23:56 known_hosts.old

On server:

drwx------ 2 root root 4096 Mar 3 23:11 .

drwxr-xr-x 4 root root 4096 Mar 3 23:18 ..

-rw-r--r-- 1 root root 1411 Mar 3 23:11 authorized_keys

-rw------- 1 root root 135 Mar 3 23:11 config

-rw------- 1 root root 20972 Mar 3 23:11 known_hosts

Why is the server not accepting my RSA key and then not logging anything about rejecting it?

--

Jack Waugh

2 Replies

````
debug3: Incorrect RSA1 identifier
debug3: Could not load "/home/jack/.ssh/id_rsa" as a RSA1 public key

Check that the id_rsa file contains the correct key

-----BEGIN RSA PRIVATE KEY-----

-----END RSA PRIVATE KEY-----

Also check that the output of: (which should be inside the id_rsa.pub, but has no bearing)

ssh-keygen -y -f ~/.ssh/id_rsa

````
matches one of the lines in the authorized_keys on the host

I am truly a retard. I wasn't using the up-to-date content for the authorized_keys file, and the version I used didn't have my RSA public key. Thanks for the solution. Also thanks for informing me that a public key can be derived from a private key, as I had assumed that the keys related to each other symmetrically.

Jack Waugh

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct