一、解压现有模板
# 进入模板目录
cd /var/lib/vz/template/cache
# 解压模板(以Ubuntu为例)
mkdir temp_template
cd temp_template
# 解压ubuntu
zstd -d -c ../ubuntu-24.10-standard_24.10-1_amd64.tar.zst | tar -xf -
# 解压debian
zstd -d -c ../debian-13-standard_13.1-1_amd64.tar.zst | tar -xf -
二、修改模板内容
# 修改SSH配置
nano etc/ssh/sshd_config
添加配置
PermitRootLogin yes
PasswordAuthentication yes
PubkeyAuthentication yes
三、重新打包模板
# 重新打包ubuntu
tar -cf - * | zstd -19 -T0 > ../ubuntu-24.10-standard_24.10-1_amd64.tar.zst
# 重新打包debian
tar -cf - * | zstd -19 -T0 > ../debian-13-standard_13.1-1_amd64.tar.zst
# 清理临时文件
cd ..
rm -rf temp_template