From 846a56a368b146cd2e568ff488ba4be5a854e54f Mon Sep 17 00:00:00 2001 From: xking Date: Sun, 10 Sep 2023 13:41:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0debian=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96=E5=AE=89=E8=A3=85=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/debian-preseed.cfg | 131 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 debian/debian-preseed.cfg diff --git a/debian/debian-preseed.cfg b/debian/debian-preseed.cfg new file mode 100644 index 0000000..2889670 --- /dev/null +++ b/debian/debian-preseed.cfg @@ -0,0 +1,131 @@ +#_preseed_V1 + +# +# Preseed configuration for debian 11/bullseye +# +# ATTENTION: This preseed configuration ERASES the target disks +# without any confirmation whatsoever. +# + +# Locale +d-i debian-installer/locale string en_US +d-i debian-installer/locale string en_US.UTF-8 +d-i keyboard-configuration/xkb-keymap select us + + +# Network +d-i hw-detect/load_firmware boolean false +d-i netcfg/enable boolean true +d-i netcfg/choose_interface select auto +d-i netcfg/hostname string unassigned-preseed +d-i netcfg/get_hostname string unassigned-preseed +d-i netcfg/get_domain string local + + +# Apt +d-i apt-setup/cdrom/set-first boolean false +d-i apt-setup/cdrom/set-next boolean false +d-i apt-setup/cdrom/set-failed boolean false +d-i cdrom-detect/try-again boolean false +d-i mirror/country string manual +d-i mirror/http/hostname string ftp.cn.debian.org +d-i mirror/http/directory string /debian +d-i mirror/http/proxy string + + +# Users/passwords +d-i passwd/root-login boolean true +d-i passwd/make-user boolean false +#使用 密文 mkpasswd -m sha-512 +d-i passwd/root-password-crypted password $6$XERIk3K43HXcQSmN$UIc6rUH/129Cz5YtN1zQGzU2pleOtl0YbYzyfdIMkeBGzE3qunqBMZtdAIhpIVwsu/cz3CqiL8uJx67spWz810 + +#使用明文 +#d-i passwd/root-password password Xking123456;a +#d-i passwd/root-password-again password Xking123456;a + + +# Clock +d-i clock-setup/cst boolean true +d-i time/zone string Asia/Shanghai +d-i clock-setup/ntp boolean true + + +# Disk partition +d-i partman/early_command string \ + BOOT_DEV=$(list-devices disk | head -1) ; \ + debconf-set partman-auto/disk $BOOT_DEV + +d-i partman-auto/method string regular +d-i partman-auto/choose_recipe select atomic +d-i partman-auto/expert_recipe string \ + 50 100 50 fat32 \ + $primary{ } \ + method{ efi } \ + format{ } \ + . \ + 1000 8000 -1 ext4 \ + $primary{ } \ + method{ format } \ + format{ } \ + use_filesystem{ } \ + filesystem{ ext4 } \ + mountpoint{ / } \ + . \ + 2048 4096 4096 linux-swap \ + $primary{ } \ + method{ swap } \ + format{ } \ + . + + +d-i partman-lvm/device_remove_lvm boolean true +d-i partman-md/device_remove_md boolean true +d-i partman/confirm_nooverwrite boolean true +d-i partman-efi/non_efi_system boolean true +d-i partman/confirm_write_new_label boolean true +d-i partman/confirm boolean true +d-i partman/choose_partition select Finish partitioning and write changes to disk + + +# Packages +d-i base-installer/install-recommends boolean false +d-i base-installer/kernel/image string linux-image-amd64 +d-i apt-setup/use_mirror boolean true + +d-i pkgsel/include string openssh-server build-essential + +tasksel tasksel/first multiselect standard, ssh-server + +d-i pkgsel/include string vim sudo +d-i pkgsel/upgrade select safe-upgrade +popularity-contest popularity-contest/participate boolean true + + +# Boot +d-i grub-installer/only_debian boolean true +d-i debian-installer/add-kernel-opts string cgroup_enable=memory swapaccount=1 +d-i grub-installer/with_other_os boolean true +d-i grub-installer/force-efi-extra-removable boolean true +d-i grub-installer/progress/step_force_efi_removable boolean true +d-i grub-installer/bootdev string default + + +# Custom late commands +d-i preseed/late_command string \ + HOST_SERIAL="debian-$(head /dev/urandom | tr -dc a-z | head -c10)" ; \ + sed -i "s/unassigned-preseed/$HOST_SERIAL/g" /target/etc/hostname ; \ + sed -i "s/unassigned-preseed/$HOST_SERIAL/g" /target/etc/hosts ; \ + in-target sh -c 'mkdir -pv --mode=0700 /root/.ssh'; \ + in-target sh -c 'echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD2NB5cURpatXqcEVfr6C6Eg6Tr591eFPwhqkuvifBabDKlzqEkpUgBsbbNv+k8GCgcraFrCL1q90QI+Ou5FNHduPkKNYxxO0oFRc/d4odj5JBuCTYICbTFPrlA7kIV+5ePBw1w8jzgUehwLzq3QDdujC0LmRtn2TOheupz8yl0YCGqxypM4Q49ZU3AgpjxzzETwO6u1XGO7q9VXm1ed39RE4nyIRJ4PxKyFbBxiaeFD3NbPkzviBU2XPI9WrmBEOSfuuwopJGyl7YwT+Jm3flJO7nunVaFbbYhrggfN3JXyaL3EN0nzmeFBHcpwiUsu0avj0OtBLjuTNGnQygz429r8PuBAPaj1XBt+X9lNJElnGjCInon2UHA4Cq3NBJMTw2OhGvejhfPE41E8aJFxeXqyyl8E7nxzQQsUDdqt0k3SxKv4AMV8+NgUQGNHAzY1+7Y6nBecD5o1Cv9u7OniB9IBE6qjbh74gmW1jofOK+Erw9Vgd+Bm20bzdZXyq89oSk= xuwei@Xking" > /root/.ssh/authorized_keys'; \ + in-target chown --recursive root:root /root/.ssh; \ + in-target chmod 0600 /root/.ssh/authorized_keys; \ + in-target update-alternatives --set editor /usr/bin/vim.basic; \ + in-target sed -i -e 's/^\(PasswordAuthentication\).*/\1 yes/g' /etc/ssh/sshd_config; \ + # in-target sed -i -e 's/^\(PermitRootLogin\).*/\1 yes/g' /etc/ssh/sshd_config; \ + in-target sed -i -e '/^GRUB_HIDDEN_TIMEOUT=/d' -e 's/^\(GRUB_HIDDEN_TIMEOUT_QUIET\)=true/\1=false/' /etc/default/grub; \ + in-target systemctl enable --now sshd; \ + in-target update-grub + + +# Finish +d-i finish-install/reboot_in_progress note