一、VPS厂商的方法:
debian9 需要换源

先运行一键换源命令(复制回车即可)

#替换为官方源(注意版本)
wget -O /etc/apt/sources.list https://static.lty.fun/%E5%85%B6%E4%BB%96%E8%B5%84%E6%BA%90/SourcesList/Debian-9-archive.list

#替换为腾讯源(注意版本)
wget -O /etc/apt/sources.list https://static.lty.fun/%E5%85%B6%E4%BB%96%E8%B5%84%E6%BA%90/SourcesList/Debian-9-archive-qcloud.list

先运行上面的命令,任选一个运行即可,运行后再运行下方命令完成换源
apt-get update -y && apt-get install curl -y && apt-get install sudo -y

添加swap交换
curl -L https://raw.githubusercontent.com/spiritLHLS/addswap/main/addswap.sh -o addswap.sh && chmod +x addswap.sh && bash addswap.sh

二、网上搜索的方法:
由于debian9 停止维护,目前可用的软件源如下:

deb http://archive.debian.org/debian/ stretch main contrib non-free

deb-src http://archive.debian.org/debian/ stretch main contrib non-free

deb http://archive.debian.org/debian-security/ stretch/updates main contrib non-free

deb-src http://archive.debian.org/debian-security/ stretch/updates main contrib non-free

deb http://archive.debian.org/debian/ stretch-backports main contrib non-free

1.设置软件源

cat >/etc/apt/sources.list<

2.更新软件源:apt update -y

3.提示gpg证书错误处理

报错信息:

W: GPG error: http://archive.debian.org/debian stretch-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY 0E98404D386FA1D9

安装需要的依赖和软件:

apt-get install software-properties-common dirmngr -y

添加gpg证书验证:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keysapt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138 0E98404D386FA1D9

4.再次执行更新软件源:apt update -y