操作步骤 添加国内软件源 1 2 3 4 5 6 cat <<-EOF >> /etc/apt/sources.list deb http://mirrors.163.com/debian/ buster main contrib non-free deb http://mirrors.ustc.edu.cn/debian/ buster main contrib non-free deb http://mirrors.aliyun.com/debian/ buster main contrib non-free EOF apt update && apt upgrade -y
安装Live构建环境应用程序 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 apt install -y \ debootstrap \ squashfs-tools \ xorriso \ mmdebstrap \ live-build \ grub-pc-bin \ grub-efi-amd64-bin \ openssh-server \ mtools \ isolinux \ net-tools \ git \ curl \ vim
设置构建首选镜像站点 1 2 3 4 5 6 mkdir -p /etc/live cat <<-EOF >> /etc/live/build.conf LB_MIRROR_BOOTSTRAP="http://mirrors.163.com/debian/" LB_MIRROR_CHROOT_SECURITY="http://mirrors.163.com/debian-security/" LB_MIRROR_CHROOT_BACKPORTS="http://mirrors.163.com/debian-backports/" EOF
添加环境变量和代理设置 1 2 3 4 5 6 7 cat <<-EOF >> ~/.bashrc export PATH=/usr/sbin:PATH export http_proxy=http://win_ip:1080 export https_proxy=http://win_ip:1080 export ftp_proxy=http://win_ip:1080 EOF source ~/.bashrc
设置SSH服务允许root远程登陆 1 2 3 4 sed -i /etc/ssh/sshd_config \\ -e 's/^PermitRootLogin .*/PermitRootLogin yes' \\ -e 's/#PasswordAuthentication yes/PasswordAuthentication yes' systemctl enable ssh
给普通用户添加sudo权限 1 2 3 4 5 chmod +w /etc/sudoers cat <<-EOF >> /etc/sudoers username ALL=(ALL:ALL) ALL EOF chmod -w /etc/sudoers