Debian 12/13更换国内软件仓库源的方法

一般情况下,将 /etc/apt/sources.list 文件中 Debian 默认的源地址 http://deb.debian.org/ 替换为镜像地址即可。
Debian Buster 以上版本默认支持 HTTPS 源。如果遇到无法拉取 HTTPS 源的情况,请先使用 HTTP 源并安装:

sudo apt install apt-transport-https ca-certificates

#编辑文件,在/etc/apt/sources.list.d/编辑sources.list文件,nano命令:ctrl+o保存,enter回车确认,ctrl+X退出,ctrl+k删除行/剪切

sudo nano /etc/apt/sources.list

#写入内容Debian版本【Debian 13(trixie)】,启用源码镜像【否】,使用官方安全更新软件源选择【否】,sources.list文件写入:

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.ustc.edu.cn/debian/ trixie main contrib non-free non-free-firmware
# deb-src https://mirrors.ustc.edu.cn/debian/ trixie main contrib non-free non-free-firmware

deb https://mirrors.ustc.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.ustc.edu.cn/debian/ trixie-updates main contrib non-free non-free-firmware

deb https://mirrors.ustc.edu.cn/debian/ trixie-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.ustc.edu.cn/debian/ trixie-backports main contrib non-free non-free-firmware

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb https://mirrors.ustc.edu.cn/debian-security trixie-security main contrib non-free non-free-firmware
# deb-src https://mirrors.ustc.edu.cn/debian-security trixie-security main contrib non-free non-free-firmware

# deb https://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware
# # deb-src https://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware

#执行升级命令如下:

sudo apt clean
sudo apt update
sudo apt list --upgradable  #查看需要升级的文件清单
sudo apt upgrade

立即关机执行命令:

sudo shutdown -h now

国内镜像源参考:https://help.mirrors.cernet.edu.cn/debian/,建议中国科技技术大学开源软件镜像,比较快。

如果SSH登陆出现这个提示

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

出现该问题是由于远程的主机的公钥发生了变化导致的。
解决方法:使用命令清除所连接的IP或hostname

ssh-keygen -R 192.168.1.11  #改成登陆的IP地址

原创文章,作者:开心电脑网,如若转载,请注明出处。

(6)
上一篇 2024年7月9日
下一篇 2025年8月25日

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注