1

Some services SSH die after restart on Ubuntu... Or so they say. The status is "inactive (dead)", but you can connect to the server. What could be the problem here? What can one check?

Some factors that might be important:

  • Those are virtual servers on a Proxmox 8 host (ZFS/LXC).
  • Things worked fine on CentOS with mostly the same things running under the hood (same types of services, same physical infrastructure).
  • Recently migrated to Ubuntu 22.04.2 LTS (reinstalled services on new virtual machines).
  • When SSH is "inactive" I can connect to it.
  • When SSH is "inactive" it is not logging anything. E.g. this is empty: journalctl -u ssh --since yesterday
  • When SSH is "inactive" it is unstable. E.g. scp gets disconnected randomly when running a script (a script that used to work fine and was very stable before migration to Ubuntu).

log for checking servers

Here is a loop that I use to check services:

# check ssh service status
# (xargs = trim)
for someServer in ${serverList[@]}
do
 connectionString=`getConnectionString "$someServer"`
 status=`ssh $connectionString "service ssh status | grep active" | xargs`
 printf "%15s: $status\n" $someServer
done

Full status info:

# service ssh status
○ ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: inactive (dead)
       Docs: man:sshd(8)
             man:sshd_config(5)
Nux
  • 81
  • 9
  • 2
    Please don't post screenshots of text. Copy the text here and use code formatting. Also: ssh uses socket activation on newer versions of Ubuntu, so the status of the service itself doesn't mean much. https://askubuntu.com/q/963705/158442 – muru Sep 05 '23 at 15:56
  • @muru This is not a code, this is a screen from a terminal and I only got a screenshot as I already restarted the services. The info is added as text as well. – Nux Sep 12 '23 at 10:54
  • Not just code, but command output, logs, etc. are all supposed to be added to posts using code formatting. Use screenshots only if the appearance of the text matters, like colours. – muru Sep 12 '23 at 11:12

1 Answers1

0

The problem was caused by ssh.socket running on Ubuntu. When you set it to disabled, the SSH service starts up nicely after a restart.

As a side note, AppArmor was also not running correctly on LXC, at least on Proxmox 7 and 8. AppArmor is a dependency of the SSH service. It appears that AppArmor may not be necessary if other precautions are taken.

Nux
  • 81
  • 9