之前一直使用天权璇玑的一键 DD 脚本,但是应该是作者挺忙的,项目页面近 1 年都没有更新和维护,最近 Debian 13 上线后,虽然脚本也可用,但我自己测试下来,在已经是 Debian 13 的情况下,再次 DD Debian 13 会容易出现失联的情况。
而另一个使用比较广泛的 煎饼佬的 DD 脚本就在 13 出来的同时,就对 Debian 13 做了更新支持。
DD 脚本项目地址
https://github.com/bin456789/reinstall
一键 DD 脚本
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh && bash reinstall.sh debian 13 --ssh-port 12345 --password woshimima && reboot
DD 脚本的系统版本、 ssh 端口和 password 可自行修改(ssh 端口和 root 密码不要使用脚本默认)。
因为这个 DD 脚本在使用时的可自定义参数不多,只能指定 ssh 端口和密码,所以我又写了一个自用的系统优化一键设置脚本,方便在 DD 系统后按照个人需求一键优化系统。
自用系统优化设置项目地址
https://github.com/yahuisme/vps-setup
项目特点
- 安装常用软件
- 设置主机名、时区和 DNS
- 配置时间同步、BBR 和 Swap
- 修改 SSH 端口和 root 密码
- 配置 Fail2ban
- 更新和清理系统
一键配置脚本
apt-get update -y && apt-get install -y curl && bash <(curl -fsSL https://raw.githubusercontent.com/yahuisme/vps-setup/main/install.sh)
脚本默认配置:
- 常用软件包
- 主机名、时区和 DNS
- 时间同步、BBR 和 Swap
- SSH 端口和 root 密码
- Fail2ban
默认不执行系统升级和清理。
无交互自定义
apt-get update -y && apt-get install -y curl && curl -fsSLo install.sh https://raw.githubusercontent.com/yahuisme/vps-setup/main/install.sh && chmod +x install.sh && ./install.sh --hostname "hostname" --timezone "Asia/Hong_Kong" --swap 1024 --bbr --ip-dns "94.140.14.14 1.1.1.1" --ip6-dns "2a10:50c0::ad1:ff 2606:4700:4700::1111" --ssh-port 12345 --fail2ban --non-interactive
参数
--hostname <name> 设置主机名
--timezone <tz> 设置时区
--swap <auto|MB|0> 设置 Swap;0 表示禁用全部 Swap
--ip-dns "主DNS 备用DNS" 设置 IPv4 DNS
--ip6-dns "主DNS 备用DNS" 设置 IPv6 DNS
--bbr 启用 BBR
--no-bbr 禁用 BBR
--fail2ban 启用 Fail2ban,保护 SSH
--no-fail2ban 禁用 Fail2ban
--ssh-port <port> 设置 SSH 端口
--ssh-password <pass> 设置 root 密码
--upgrade 执行系统 full-upgrade
--cleanup 执行 autoremove 和 apt clean
--non-interactive 非交互模式
-h, --help 显示帮助
注意
- 仅支持完整 VPS / 虚拟机,不支持容器环境。
- 修改 SSH 端口前,请先放行云平台安全组和防火墙端口。
--ssh-password会暴露在 shell 历史和进程参数中,仅建议临时使用。--swap 0会关闭全部 Swap 并移除/etc/fstab中的 Swap 条目。/etc/resolv.conf由其他 DNS 管理器维护时,脚本会跳过直接修改并给出警告。- 日志保存到
/var/log/vps-init-日期时间.log。
叶彩
这个脚本很不错呀,支持大佬,已加星