在配置arm64v8/Ubuntu22.04镜像时,apt 失败,切换到国内源同样报错
究其原因是arm64v8/Ubuntu22.04是个精简镜像,没有ca证书, 需要安装ca-certificates, 但apt 不能用,死锁了。
根据网上/AI 提示, 下面三个方法均不起作用:
- 导入缺失的 GPG 公钥
> apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C
不起作用:" gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation"
- 手动下载并添加公钥
> gpg --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C
> gpg --export 871920D1991BC93C | tee /etc/apt/trusted.gpg.d/ubuntu-ports.gpg > /dev/null
不起作用:"gpg: command not found"
- 修复密钥文件的权限
>chmod 644 /etc/apt/trusted.gpg.d/*.gpg
不安全的解决方法
方法1. 所有apt update 增加参数 --allow-insecure-repositories --allow-unauthenticated
apt install增加参数 --allow-unauthenticated
> apt update --allow-insecure-repositories --allow-unauthenticated
> apt install --allow-unauthenticated xxxx
方法2. 修改 /etc/apt/sources.list
deb 后面增加**trusted=yes**
deb trusted=yes http://mirrors.aliyun.com/ubuntu-ports/ jammy main restricted universe multiverse
deb trusted=yes http://mirrors.aliyun.com/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb trusted=yes http://mirrors.aliyun.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb trusted=yes http://mirrors.aliyun.com/ubuntu-ports/ jammy-security main restricted universe multiverse
但上面方法都是直接取消安全验证,所以是不安全的。
。