Hirza_Tango
Posts: 6
Joined: Tue Aug 02, 2016 3:25 pm

SSH server closes connections

Wed Dec 14, 2016 1:13 pm

Whenever I attempt co connect to my Pi3's ssh server, I get "Connection closed by <ip> port 22".

This is on a fresh Raspbian Jessie 11-25 install.

Attached is the output from

Code: Select all

ssh -vvv pi@192.168.1.33
http://pastebin.com/Q5GfNAbZ

I tried

Code: Select all

ssh -vvv pi@localhost
on the pi with similar results.



Thanks in advance!

klricks
Posts: 7229
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: SSH server closes connections

Wed Dec 14, 2016 1:33 pm

SSH is now disabled by default in all present and future Raspbian OS releases.
Use the RPi configuration tool in [menu] --> [Preferences] or sudo raspi-config to enable SSH.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

Hirza_Tango
Posts: 6
Joined: Tue Aug 02, 2016 3:25 pm

Re: SSH server closes connections

Wed Dec 14, 2016 1:36 pm

Ssh has been enabled, as evidenced by the fact that the log shows that a connection was established and the remote protocol version was given.

wh7qq
Posts: 1475
Joined: Thu Oct 09, 2014 2:50 am

Re: SSH server closes connections

Sat Dec 17, 2016 1:25 am

klricks wrote:SSH is now disabled by default in all present and future Raspbian OS releases.
Use the RPi configuration tool in [menu] --> [Preferences] or sudo raspi-config to enable SSH.
Yes, they "fixed" it so it doesn't work at all. Raspi-config, either command line or GUI is no help and putting in the /boot/ssh file per their blog does no good...so it is very safe indeed...you just can't use it. I think I still have the previous iso on another drive...will get it back and get rid of this garbage until the masters of the piniverse fix it so it can be used.

Edit:
After my previous tantrum, I went back and looked for my old version of jessie/pixel but I had already deleted it...so back to work. Not quite sure what fixed it but I am now able to login by ssh to this RPi. I did two things. First, I used the old linux/unix standby command "passwd" to enter a new password.

Code: Select all

passwd pi
I also logged in with

Code: Select all

ssh pi@localhost
with the new password. With that giving a happy result, I logged in using ssh on another RPi and then back to this one with the new password and all went well. I reiterate that the configuration utilities, either cli or GUI were useless to fixing this problem.

No apologies to the maintainers...to screw up a previously useable access without serious debugging/workarounds on a computer that is supposedly aimed at children and others with little experience...well, what can I say. This is a cluster-****.
Last edited by wh7qq on Sat Dec 17, 2016 2:56 am, edited 2 times in total.

klricks
Posts: 7229
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: SSH server closes connections

Sat Dec 17, 2016 2:46 am

wh7qq wrote:
klricks wrote:SSH is now disabled by default in all present and future Raspbian OS releases.
Use the RPi configuration tool in [menu] --> [Preferences] or sudo raspi-config to enable SSH.
Yes, they "fixed" it so it doesn't work at all. Raspi-config, either command line or GUI is no help and putting in the /boot/ssh file per their blog does no good...so it is very safe indeed...you just can't use it. I think I still have the previous iso on another drive...will get it back and get rid of this garbage until the masters of the piniverse fix it so it can be used.
Not sure what your issue is?
I tried all 3 enableing methods and they all work for me.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

Hirza_Tango
Posts: 6
Joined: Tue Aug 02, 2016 3:25 pm

Re: SSH server closes connections

Sat Dec 17, 2016 9:13 am

SSH is enabled, that's not the problem. The port is identified in the log and by telnet as an SSH server

User avatar
HawaiianPi
Posts: 5967
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: SSH server closes connections

Sat Dec 17, 2016 10:34 am

wh7qq wrote:Yes, they "fixed" it so it doesn't work at all. Raspi-config, either command line or GUI is no help and putting in the /boot/ssh file per their blog does no good...so it is very safe indeed...you just can't use it. I think I still have the previous iso on another drive...will get it back and get rid of this garbage until the masters of the piniverse fix it so it can be used...
It works perfectly for me by putting the "ssh" file into /boot. If it's not working for you then something is wrong on your end. Bad SD card? Bad imaging procedure? Not correctly creating the ssh file (having known file extension on Windows set to hidden, so that you don't see that the file you actually created is ssh.txt)?
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

klricks
Posts: 7229
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: SSH server closes connections

Sat Dec 17, 2016 3:46 pm

Hirza_Tango wrote:SSH is enabled, that's not the problem. The port is identified in the log and by telnet as an SSH server
After enabling of course I tested each case by connecting to the RPi using PuTTY from a Windows 10 computer.
I conneceted using IP address which I have reserved in my routers DHCP reservations table.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

User avatar
jojopi
Posts: 3316
Joined: Tue Oct 11, 2011 8:38 pm

Re: SSH server closes connections

Sat Dec 17, 2016 4:11 pm

Loss of connection after "SSH2_MSG_KEXINIT sent" may be because the host keys are missing or corrupt. Try regenerating:

Code: Select all

sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server
Also, check for errors in /var/log/auth.log.

mattat01
Posts: 3
Joined: Thu May 28, 2015 11:05 am

Re: SSH server closes connections

Thu Jan 05, 2017 9:54 am

jojopi wrote:Loss of connection after "SSH2_MSG_KEXINIT sent" may be because the host keys are missing or corrupt. Try regenerating:

Code: Select all

sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server
Also, check for errors in /var/log/auth.log.
This worked for me. Thanks!

arastehfazel
Posts: 1
Joined: Sun Aug 27, 2017 9:59 pm

Re: SSH server closes connections

Sun Aug 27, 2017 10:07 pm

jojopi wrote: Loss of connection after "SSH2_MSG_KEXINIT sent" may be because the host keys are missing or corrupt. Try regenerating:

Code: Select all

sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server
Also, check for errors in /var/log/auth.log.
I don't have my LCD working. And I need the ssh to fix my LCD .I mean I'm completely headless. The ssh file didn't work for me and raspberry closes the connection automatically. is there any way for me to try this solution?

jorgeg73
Posts: 19
Joined: Sun Apr 27, 2014 4:34 am

Re: SSH server closes connections

Sun Feb 25, 2018 5:19 am

I am like you, ever found a solution?

jbudd
Posts: 1466
Joined: Mon Dec 16, 2013 10:23 am

Re: SSH server closes connections

Sun Feb 25, 2018 6:11 am

I am like you, ever found a solution?
The best way to get help is to start a fresh thread.
Describe your actual problem as it is now.

Are you really running Raspbian Jessie? Lots of things have changed since the original post in 2016, and the original poster has not been active in the forum since March 2017

mikenike360
Posts: 2
Joined: Wed May 16, 2018 5:31 pm

Re: SSH server closes connections

Mon May 28, 2018 3:54 pm

Here is a fix:

sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server

Return to “Troubleshooting”