el: 删除国产系统镜像的默认账户,防止使用默认账户密码登录 ssh
This commit is contained in:
parent
6fd3f18b54
commit
fc12aa67ab
14
trans.sh
14
trans.sh
@ -2239,6 +2239,17 @@ chroot_apt_autoremove() {
|
||||
mv $conf.orig $conf
|
||||
}
|
||||
|
||||
del_default_user() {
|
||||
os_dir=$1
|
||||
|
||||
while read -r user; do
|
||||
if grep ^$user':\$' "$os_dir/etc/shadow"; then
|
||||
echo "Deleting user $user"
|
||||
chroot "$os_dir" userdel -rf "$user"
|
||||
fi
|
||||
done < <(grep -v nologin$ "$os_dir/etc/passwd" | cut -d: -f1 | grep -v root)
|
||||
}
|
||||
|
||||
install_qcow_by_copy() {
|
||||
mount_nouuid() {
|
||||
case "$(get_os_fs)" in
|
||||
@ -2384,6 +2395,9 @@ install_qcow_by_copy() {
|
||||
# resolv.conf
|
||||
cp_resolv_conf /os
|
||||
|
||||
# 删除镜像的默认账户,防止使用默认账户密码登录 ssh
|
||||
del_default_user /os
|
||||
|
||||
# selinux kdump
|
||||
disable_selinux_kdump /os
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user