0

Setup Info

I am using Hyper-V to spawn Ubuntu live 22.04 VMs. During the installation procedure it asks if I want to Install OpenSSH server, whether I select this option only results in one change. The change: Cloud init creates a conf file in the /etc/ssh/sshd_config.d/ called 50-cloud-init.conf. There might be other changes, but this is the only change I have noticed.

the contents of 50-cloud-init.conf

PasswordAuthentication yes

VM that doesn't have OpenSSH option checked

sudo systemctl status sshd

test@bingbong [19:07:22] [/etc/ssh/sshd_config.d]
-> % sudo systemctl status sshd
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-10-05 17:40:55 UTC; 1h 26min ago
       Docs: man:sshd(8)
             man:sshd_config(5)
   Main PID: 909 (sshd)
      Tasks: 1 (limit: 2140)
     Memory: 6.7M
        CPU: 100ms
     CGroup: /system.slice/ssh.service
             └─909 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Oct 05 17:40:55 bingbong systemd[1]: Started OpenBSD Secure Shell server.
Oct 05 17:41:38 bingbong sshd[1281]: Accepted publickey for test from 192.168.0.28 port 51602 ssh2: RSA SHA256:wm5N8Nv0>
Oct 05 17:41:38 bingbong sshd[1281]: pam_unix(sshd:session): session opened for user test(uid=1000) by (uid=0)
Oct 05 18:02:01 bingbong sshd[3090]: Connection closed by 192.168.0.28 port 62394 [preauth]
Oct 05 18:02:38 bingbong sshd[3092]: Connection closed by 192.168.0.28 port 62395 [preauth]
Oct 05 18:03:14 bingbong sshd[3096]: Accepted publickey for test from 192.168.0.28 port 51604 ssh2: RSA SHA256:wm5N8Nv0>
Oct 05 18:03:14 bingbong sshd[3096]: pam_unix(sshd:session): session opened for user test(uid=1000) by (uid=0)
Oct 05 18:12:52 bingbong sshd[3692]: Connection closed by 192.168.0.28 port 62466 [preauth]
Oct 05 18:13:04 bingbong sshd[3694]: Accepted publickey for test from 192.168.0.28 port 51592 ssh2: RSA SHA256:wm5N8Nv0>
Oct 05 18:13:04 bingbong sshd[3694]: pam_unix(sshd:session): session opened for user test(uid=1000) by (uid=0)

VM that does have OpenSSH option checked

test@worker1:~$ sudo systemctl status sshd
[sudo] password for test:
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-10-05 17:51:50 UTC; 1h 14min ago
       Docs: man:sshd(8)
             man:sshd_config(5)
    Process: 1427 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS)
   Main PID: 1428 (sshd)
      Tasks: 1 (limit: 2140)
     Memory: 4.0M
        CPU: 26ms
     CGroup: /system.slice/ssh.service
             └─1428 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Oct 05 17:51:50 worker1 systemd[1]: Starting OpenBSD Secure Shell server...
Oct 05 17:51:50 worker1 sshd[1428]: Server listening on 0.0.0.0 port 22.
Oct 05 17:51:50 worker1 sshd[1428]: Server listening on :: port 22.
Oct 05 17:51:50 worker1 systemd[1]: Started OpenBSD Secure Shell server.
Oct 05 19:06:04 worker1 sshd[1650]: Accepted password for test from 192.168.0.188 port 50394 ssh2
Oct 05 19:06:04 worker1 sshd[1650]: pam_unix(sshd:session): session opened for user test(uid=1000) by (uid=0)

Issue

What is the use of checking the option Install OpenSSH Server during the installation of a Ubuntu Live Server 22.04? what am I missing?

0

1 Answer 1

3

There is a bug with the 22.04 live-server installer that causes openssh-server to always be installed regardless of the installer selections.

Bug 1974483 describes the issue in more detail. Essentially, openssh-server was accidentally included in the base image copied during installation.

The installer generates cloud-init configuration in /etc/cloud/cloud.cfg.d/99-installer.cfg. If you enable the "Install OpenSSH Server" option then this configuration will include content for cloud-init modules to modify the ssh configuration. E.g. ssh_pwauth: true. During the first boot, cloud-init generates the file you see in /etc/ssh/sshd_config.d/. In some cases, cloud-init will modify the file /etc/ssh/sshd_config instead of creating a new file.

2
  • Thank you for the insight! I thought I was going crazy. Do you perhaps have an idea why it creates a cloud-init.conf file when I check the Install OpenSSH Server option?
    – Souldiv
    Commented Oct 5, 2023 at 23:48
  • 1
    @Souldiv I updated the answer with more info about what cloud-init is doing Commented Oct 6, 2023 at 21:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .