Max grabbed the journal (attached), which explains what's going on:

openssh-server is not already installed, the first boot installs it. But
this happens in /etc/rc.local, which we run fairly early (right after
the network is up). In the journal we see roughly this order:

784:Apr 08 13:52:27 utah-12201-xenial-amd64 systemd[1]: Reached target Network.
899:Apr 08 13:52:35 utah-12201-xenial-amd64 utah[1046]: Installing 
openssh-server...
900:Apr 08 13:52:35 utah-12201-xenial-amd64 sudo[1047]:     root : TTY=unknown 
; PWD=/ ; USER=root ; COMMAND=/usr/bin/apt-get install -y openssh-server 
--force-yes
940:Apr 08 13:53:47 utah-12201-xenial-amd64 systemd[1]: Reached target Login 
Prompts.
941:Apr 08 13:53:47 utah-12201-xenial-amd64 systemd[1]: Reached target 
Multi-User System.
942:Apr 08 13:53:47 utah-12201-xenial-amd64 systemd[1]: Reached target 
Graphical Interface.

I. e. installing the openssh-server package is happening while the boot
transaction is still going on; installing new units during that time
won't cause the dependency tree of graphical.target to be recomputed, so
it's not taken into account for starting.

A cleaner way would be to install openssh-server during OS install, not
as part of first boot. Another option is to wait until the VM is booted,
and then install it (if you have some way to access the VM in another
way than ssh, such as the serial console).

A more hackish, but perhaps simpler way would be to change rc.local to
wait until the system is booted with something like

  while true; do
      s=`systemctl is-system-running` || true
      [ "$s" != running -a "$s" != degraded ] || break
      sleep 1
  done

and only then install openssh-server.

(Checking for "degraded" is more robust in case the default installtion has 
some broken units which fail to start. This happens from time to time, like bug 
1567780)
     

** Attachment added: "journal from first boot"
   
https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/1554266/+attachment/4629081/+files/journal.txt

** Changed in: openssh (Ubuntu)
       Status: Incomplete => Triaged

** Package changed: openssh (Ubuntu) => utah

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1554266

Title:
  sshd does not start on newly installed desktop system

To manage notifications about this bug go to:
https://bugs.launchpad.net/utah/+bug/1554266/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to