From d3fe57a4d2322cd3ccca5b7aef6db6b6a0110164 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Thu, 22 Feb 2024 08:45:29 +0800 Subject: [PATCH] Update sh_insert_content.text --- sh_insert_content.text | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sh_insert_content.text b/sh_insert_content.text index aab0a41..3219d1e 100644 --- a/sh_insert_content.text +++ b/sh_insert_content.text @@ -5,12 +5,13 @@ cd /etc/ssh || true ssh-keygen -A || true + sed -i "s/^#\?\(Port\).*/\1 22/" /etc/ssh/sshd_config || true + sed -i -E 's/^#?(Port).*/\1 22/' /etc/ssh/sshd_config || true + sed -i 's/^#\?Port.*/Port 22/g' /etc/ssh/sshd_config || true sed -i '/^#PermitRootLogin\|PermitRootLogin/c PermitRootLogin yes' /etc/ssh/sshd_config || true sed -i "s/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g" /etc/ssh/sshd_config || true sed -i '/^#ListenAddress\|ListenAddress/c ListenAddress 0.0.0.0' /etc/ssh/sshd_config || true sed -i '/^#AddressFamily\|AddressFamily/c AddressFamily any' /etc/ssh/sshd_config || true - sed -i "s/^#\?\(Port\).*/\1 22/" /etc/ssh/sshd_config || true - sed -i -E 's/^#?(Port).*/\1 22/' /etc/ssh/sshd_config || true sed -i '/^#UsePAM\|UsePAM/c #UsePAM no' /etc/ssh/sshd_config || true sed -E -i 's/preserve_hostname:[[:space:]]*false/preserve_hostname: true/g' /etc/cloud/cloud.cfg || true sed -E -i 's/disable_root:[[:space:]]*true/disable_root: false/g' /etc/cloud/cloud.cfg || true @@ -20,9 +21,9 @@ rc-update add sshd default || true /etc/init.d/cron enable || true /etc/init.d/cron start || true - echo "PermitRootLogin yes" >> /etc/ssh/sshd_config || true - echo "Related repo https://github.com/oneclickvirt/incus\n--by https://t.me/spiritlhl" >> /etc/motd || true - echo "Related repo https://github.com/oneclickvirt/incus\n--by https://t.me/spiritlhl" >> /etc/banner || true + grep -q '^PermitRootLogin yes' /etc/ssh/sshd_config || echo "PermitRootLogin yes" >> /etc/ssh/sshd_config || true + echo "Related repo https://github.com/oneclickvirt/lxc_amd64_images\n--by https://t.me/spiritlhl" >> /etc/motd || true + echo "Related repo https://github.com/oneclickvirt/lxc_amd64_images\n--by https://t.me/spiritlhl" >> /etc/banner || true types: - container