阿里云 Debian VPS 初始化后 Todo 清单

Aug 19, 2025 • 预计阅读时间 2 分钟

新购买的阿里云 VPS ,第一剑先砍掉阿里云的云盾和状态监控服务,可以让服务器的进程列表干净不少。

以下操作来自阿里云官方文档,如果运行过程中有变更需要以最新文档为准。

  1. 卸载阿里云盾
$ wget http://update2.aegis.aliyun.com/download/uninstall.sh
$ chmod +x ./uninstall.sh
$ sudo ./uninstall.sh

参考:https://help.aliyun.com/zh/security-center/user-guide/uninstall-the-security-center-agent

  1. 卸载阿里云监控、云助手

2.1 卸载云监控(主要是收集系统运行资源,没啥用):

$ /usr/local/share/assist-daemon/assist_daemon --stop
$ /usr/local/share/assist-daemon/assist_daemon --delete
$ sudo rm -rf /usr/local/share/assist-daemon

参考:https://help.aliyun.com/zh/ecs/user-guide/start-stop-or-uninstall-the-cloud-assistant-agent

2.2 卸载云助手:

$ dpkg -r aliyun-assist

2.3 禁用 cloud-init 管理 resolv.conf

编辑 /etc/cloud/cloud.cfg 文件,添加:

manage_resolv_conf: false
resolv_conf:
  nameservers: [127.0.0.1]

如果你想自动配置,也可以使用上面的配置,改为 true 就行了。

cloud-init 生效,或者重启系统也可以:

$ sudo cloud-init clean
$ sudo cloud-init init

如果你想完全卸载 cloud-init 也没有任何问题:

$ sudo apt purge -y cloud-init --auto-remove
  1. 卸载 systemd-resolved、安装 unbound
$ sudo systemctl stop systemd-resolved
$ sudo systemctl disable systemd-resolved

3.1 使用 unbound 作为 DNS 解析服务

默认情况下使用的是云厂商的 DNS 服务,数据是 UDP 没有加密措施,unbound 可以自定义使用 DNS over TLS ,能有效防止劫持,更安全。

sudo apt install unbound

重启系统后再配置 unbound 来接管 DNS:

$ sudo rm /etc/resolv.conf

然后重新配置 resolv.conf ,指向 127.0.0.1

nameserver 127.0.0.1

编辑 /etc/unbound/unbound.conf ,替换为以下内容:

server:
  username: unbound
  directory: /etc/unbound
  chroot: /etc/unbound
  pidfile: /run/unbound.pid
  prefer-ip6: no
  num-threads: 4
  cache-min-ttl: 7200
  cache-max-ttl: 36000
  interface: lo@53

include: /etc/unbound/forward.conf

编辑 /etc/unbound/forward.conf ,替换为以下内容:

forward-zone:
  name: "."
  forward-first: no
  forward-tls-upstream: yes
  forward-addr: 1.1.1.1@853
  forward-addr: 1.0.0.1@853

重启 unbound 服务:

$ sudo systemctl restart unbound

使用 dig 验证一下生效的是否是 unbound :

$ dig github.com

;; Query time: 56 msec
;; SERVER: 127.0.0.1#53(127.0.0.1) (UDP)
;; WHEN: Tue Aug 19 14:38:21 CST 2025
;; MSG SIZE  rcvd: 55
Debian
版权声明:如果转发请带上本文链接和注明来源。

lvv.me

iOS/macOS Developer

让 Safari 中的滚动条颜色自动适配深色模式