0

I'm using debian tested images on Raspberry Pi 4.

After installing ssh service with apt-get install ssh, i'm fancing the following issue: the service failed to start on boot only:

-- Boot 081a2e48bcac4a4eb71bac1995c5bc83 --
nov. 18 17:50:08 rpi4-20210823 systemd[1]: Starting OpenBSD Secure Shell server...
nov. 18 17:50:08 rpi4-20210823 sshd[618]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
nov. 18 17:50:08 rpi4-20210823 sshd[618]: error: Bind to port 22 on :: failed: Address already in use.
nov. 18 17:50:08 rpi4-20210823 sshd[618]: fatal: Cannot bind any address.
nov. 18 17:50:08 rpi4-20210823 systemd[1]: ssh.service: Main process exited, code=exited, status=255/EXCEPTION
nov. 18 17:50:08 rpi4-20210823 systemd[1]: ssh.service: Failed with result 'exit-code'.
nov. 18 17:50:08 rpi4-20210823 systemd[1]: Failed to start OpenBSD Secure Shell server.

But after boot, if I start it by systemctl start ssh, it works!

nov. 18 17:50:55 rpi4-20210823 systemd[1]: Starting OpenBSD Secure Shell server...
nov. 18 17:50:55 rpi4-20210823 sshd[910]: Server listening on 0.0.0.0 port 22.

Of course, I don't have any other service that bind to port 22, so I don't understand what it preventing ssh to start on boot (and as you can imagine this is quite annoying).

3
  • Of course, I don't have any other service that bind to port 22 - the error would suggest otherwise, at least at 17:50:08 something did have port 22 open - If you're using the debian tested images to run 64bit OS on pi, use the raspberry pi images instead (you'll find them at downloads.raspberrypi.org ) the 64bit Ras Pi OS uses debian.org apt sources for the most part - and I can attest to it working on 2 x pi4, a cm4 and a pi3A+
    – Bravo
    Nov 23, 2021 at 22:13
  • This does not help at all. I have reasons for using Debian and not Raspberry images, and discussing about it is not really the subject. About service on port 22 of course the message suggest this, but it's not expected and it happens on every boot. And again, the service running is closing itself, because I can start openssh just after boot ends by starting the service. Nov 24, 2021 at 16:46
  • Alright, didn't know if you were aware of the raspberry pi OS 64 bit image - I do understand, I ran "debian tested images" for a while too, headless, successfully. Perhaps it's time to scour through the logs to see what's happening on startup
    – Bravo
    Nov 24, 2021 at 22:48

1 Answer 1

0

I had this issue and solved it by

  • adding ListenAddress 0.0.0.0 to /etc/ssh/sshd_config as there was a race condition between ipv4 and ipv6
  • creating the sysconf.txt file in the boot partition mounted at /boot/firmware, some debian-rpi service was expecting it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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