sshd not running on Ubuntu 16.04

After a recent update to a VPS server I have running Ubuntu 16.04, I found that sshd was not starting automatically on boot.

The error in syslog was:

sshd[328]: Missing privilege separation directory: /var/run/sshd
systemd[1]: ssh.service: Control process exited, code=exited status=255

After a bit of investigation (and looking at Upstart scripts in /etc/init which it turned out were not being used), I found that sshd should have been started by the systemd script in /lib/systemd/system/ssh.service.

I compared this script on my 16.04 machine to the same thing on another machine running 18.04, and I spotted that it was missing these two lines:

RuntimeDirectory=sshd
RuntimeDirectoryMode=0755

Adding them in, and it all now works.

No idea what update caused it all to stop working, though.