设置信息

设置信息

设置信息

我正在使用 Hyper-V 生成 Ubuntu live 22.04 VM。在安装过程中,它会询问我是否要安装 OpenSSH 服务器,无论我是否选择此选项,都只会导致一个变化。变化:Cloud init 在/etc/ssh/sshd_config.d/名为 的文件中创建一个 conf 文件50-cloud-init.conf。可能还有其他变化,但这是我注意到的唯一变化。

的内容50-cloud-init.conf

PasswordAuthentication yes

未选中 OpenSSH 选项的虚拟机

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)

已选中 OpenSSH 选项的虚拟机

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)

问题

在安装 Ubuntu Live Server 22.04 期间选中“安装 OpenSSH 服务器”选项有什么用?我错过了什么?

答案1

22.04 实时服务器安装程序存在一个错误,openssh-server无论安装程序选择如何,都会始终进行安装。

错误 1974483更详细地描述了该问题。本质上,openssh-server它被意外地包含在安装过程中复制的基础映像中。

安装程序生成云初始化配置/etc/cloud/cloud.cfg.d/99-installer.cfg。如果启用“安装 OpenSSH 服务器”选项,则此配置将包括以下内容云初始化模块来修改 ssh 配置。例如ssh_pwauth: true。在第一次启动时,云初始化生成您在 中看到的文件/etc/ssh/sshd_config.d/。在某些情况下,云初始化将修改文件/etc/ssh/sshd_config而不是创建新文件。

相关内容