SSH connection closed immediately

To determine why the ssh connection closes immediately, try running ssh daemon on the remote computer with the verbose debugging turned on. Then look at the logging output. If it contains "key_from_blob: can't read rsa key", you may have incorrectly copied and pasted the key.

$ /usr/sbin/sshd -d

If sshd is located elsewhere, use the following:

$ $(which sshd) -d

Things to try on the local machine trying to connect to the remote machine:

If you keep getting "Enter passphrase for key" and there is no passphrase, you may be incorrectly pointing to the public key. debug1: key_parse_private2: missing begin marker debug1: key_parse_private_pem: PEM_read_PrivateKey failed

instead of:
$ ssh -v user@host -i ~/.ssh/id_rsa.pub
do this:
$ ssh -v user@host -i ~/.ssh/id_rsa

Things to try on the remote machine that you are trying to connect to using ssh:

Ensure that the ssh daemon is running:

$ sudo /etc/init.d/ssh status
* sshd is not running
$ sudo /etc/init.d/ssh start
* Starting OpenBSD Secure Shell server sshd

Possible errors: "debug1: Could not open authorized keys '/.../.ssh/authorized_keys2': No such file or directory"

Did this help you? Please let me know with a comment. Thank you
Posted .

Comments (RSS)

Leave a comment