#cloud-config datasource_list: [None] timezone: Asia/Shanghai disable_root: false ssh_pwauth: true users: - name: root lock_passwd: false chpasswd: expire: false # 20.04 arm 需要 list: | root:@PASSWORD@ users: - name: root password: "@PASSWORD@" type: text runcmd: # opensuse tumbleweed 镜像有 /etc/ssh/sshd_config.d/ 文件夹,没有 /etc/ssh/sshd_config,有/usr/etc/ssh/sshd_config # opensuse tumbleweed cloud-init 直接创建并写入 /etc/ssh/sshd_config,造成默认配置丢失 # 下面这行删除 clout-init 创建的 sshd_config - test $(wc -l >/etc/ssh/sshd_config.d/50-cloud-init.conf && rm -f /etc/ssh/sshd_config - echo "PermitRootLogin yes" >/etc/ssh/sshd_config.d/01-permitrootlogin.conf || sed -Ei 's/^#?PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config # 已创建的 ssh 连接会沿用旧的配置(未开启密码登录),这时即使输入正确的密码,也会提示 Access Denied # systemctl restart sshd 只会重启监听进程,不会关闭已创建的连接(子进程) - pkill sshd || true - systemctl restart sshd || systemctl restart ssh - touch /etc/cloud/cloud-init.disabled # ubuntu 镜像运行 echo -e '\nDone' ,-e 会被显示出来 - printf '\n%s\n' 'reinstall done' >/dev/tty0 || true