Ubuntu – sshd issue (maybe ChallengeResponseAuthentication or ‘unknown key type’ related)

sshUbuntu

After adding a new user and his pub key to ~/.ssh/authorized_keys, I couldn't ssh to my slice (Permission denied (publickey)).

So I changed (in /etc/ssh/sshd_config) ChallengeResponseAuthentication from no to yes and added him to AllowUsers. Then, after trying to ssh: Connection closed by my.IP.here

So I changed ChallengeResponseAuthentication back to no,

`sudo kill `cat /var/run/sshd.pid` && /usr/sbin/sshd`

and since then I can't log in with my admin user (piotr): Connection closed by my.IP.here.

$ ssh -p my.port.here piotr@my.IP.here -vvv
OpenSSH_5.1p1, OpenSSL 0.9.7l 28 Sep 2006
debug1: Reading configuration data /etc/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to my.IP.here [my.IP.here] port my.port.here.
debug1: Connection established.
debug1: identity file /Users/piotr/.ssh/identity type -1
debug3: Not a RSA1 key file /Users/piotr/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /Users/piotr/.ssh/id_rsa type 1
debug1: identity file /Users/piotr/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.1p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
Connection closed by my.IP.here

Best Answer

The answer is in that log:

unknown key type '-----BEGIN'

Seems like you somehow messed up your private key and ssh is no longer able to read it.