Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raspberry Pi not terminating SSH connection on reboot

This has happened to me on multiple occasions and I can't seem to pinpoint the cause of it.

Whenever I try to shutdown or reboot the Raspberry Pi via an SSH connection, the system broadcasts it's halting, but doesn't close the SSH connection. Instead it's left hanging until I type something after a minute and it notes a "Broken Pipe" error.

The weird thing about this is that it's random across installs.

On my Pi B, Rev 1, the connection closes. Initially this was the case on my Pi 3, but after a reinstall of Raspbian it stopped closing it. Another reinstall fixed it, but yesterday I reinstalled again and the problem came back.

It's seems that I'm the only one who has this problem (or at least has queried other about in online) so I thought I'd pick the brains of whoever stumbled upon this question. Anyone have any idea why this happens?

P.S. it's doesn't happen to my other servers, only to the Pi's.

like image 337
jammehcow Avatar asked Dec 28 '25 07:12

jammehcow


1 Answers

This probably happens as a result of the order of the steps performed during system shutdown.

The recommended solution is installing libpam-systemd and dbus and making sure that UsePAM is enabled in sshd_config:

apt-get install libpam-systemd dbus

See the following links for a more detailed explanation:

  • https://serverfault.com/questions/706475/ssh-sessions-hang-on-shutdown-reboot
  • https://unix.stackexchange.com/questions/216950/after-sending-shutdown-command-ssh-session-doesnt-terminate
like image 60
dwu Avatar answered Dec 31 '25 00:12

dwu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!