Search code examples
sshraspberry-piraspbian

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.


Solution

  • 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: