2

Following the recent Raspbian update, I have uploaded an SSH file to my server to be downloaded and copied into the /boot/ directory. This SSH file is a simple txt file, containing only ssh, and is intended for others to download and use whenever they install Raspbian for the first time (as per the instructions here).

When testing the SSH file, I get different results. The test procedure includes formatting the SD card, copying Raspbian onto it, copying the downloaded SSH file to the /boot/ directory, booting the Raspberry Pi and logging in via SSH.

Sometimes logging in via SSH works, other times I get the error message Connection closed by <ipv6 address> port 22.

The SSH file gets deleted when the connection is closed and sometimes the SSH file doesn't get deleted even after the connection was successful.

Why does it sometimes log in successfully and at other times the connection closes? Is there a solution to the error?

  • Given the information you provided, I'm not sure if anyone is able to answer why sometimes it works for you, and why sometimes it does not. – techraf Dec 2 '16 at 13:05
  • I don't think adding the ssh file was meant to be a permanent solution. It's really for first headless boot. Once booted you should enable SSH with sudo raspi-config. Not that this has anything to do with your connection closed message. – joan Dec 2 '16 at 13:35
  • What are you sshing from or with – sir_ian Dec 2 '16 at 13:56
  • MacOS, using iTerm – user3684814 Dec 2 '16 at 14:06
  • As suggested by @joan. Got raspi-config and enable ssh. The ssh service is not running on boot for Raspbian Pixel version. So once you enable then you may not get the connection refused issue. – Varad A G Dec 5 '16 at 10:13
1

Found a solution. Turns out that you need to allow sufficient time for the Raspberry Pi to boot and generate its SSH key. Therefore the solution is to leave the Pi for about a minute after powering it up before establishing a SSH connection.

Thanks to Simon Long, UX engineer at Raspberry Pi, who answered this question on the Raspberry Pi blog.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.