From d5369817eb95a5797755395ea8ca10c28988c76c Mon Sep 17 00:00:00 2001 From: bin456789 Date: Wed, 22 May 2024 21:48:17 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=BF=E5=85=8D=E9=A6=96=E6=AC=A1=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=20ssh=20=E6=97=A0=E6=B3=95=E7=94=A8=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloud-init.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cloud-init.yaml b/cloud-init.yaml index 729a311..4b39513 100644 --- a/cloud-init.yaml +++ b/cloud-init.yaml @@ -21,6 +21,9 @@ runcmd: # 下面这行删除 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 会被显示出来