Ubuntu 16.04 上的 ESM 401 未授权错误

Ubuntu 16.04 上的 ESM 401 未授权错误

我想将我的 Ubuntu 16.04 服务器升级到 Ubuntu 18.04,并且我正在运行以下命令来执行此操作;

apt update -y
apt upgrade -y
do-release-upgrade

apt update命令运行正常,输出如下;

# apt update -y
Hit:1 https://esm.ubuntu.com/infra/ubuntu bionic-infra-security InRelease
Hit:2 https://esm.ubuntu.com/infra/ubuntu bionic-infra-updates InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
5 packages can be upgraded. Run 'apt list --upgradable' to see them.

但是运行apt upgrade命令时,它返回以下错误;

# apt upgrade -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done

*The following packages could receive security updates with UA Infra: ESM service enabled:
  libkrb5-3 libgssapi-krb5-2 libk5crypto3 libkrb5support0 libzstd1
Learn more about UA Infra: ESM service for Ubuntu 16.04 at https://ubuntu.com/16-04

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

The following packages have been kept back:
  libk5crypto3 libkrb5support0
The following packages will be upgraded:
  libzstd1
1 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
1 esm-infra security update
Need to get 189 kB of archives.
After this operation, 132 kB of additional disk space will be used.
Err:1 https://esm.ubuntu.com/infra/ubuntu bionic-infra-security/main amd64 libzstd1 amd64 1.3.3+dfsg-2ubuntu1+esm1
  401  Unauthorized
E: Failed to fetch https://esm.ubuntu.com/infra/ubuntu/pool/main/libz/libzstd/libzstd1_1.3.3+dfsg-2ubuntu1+esm1_amd64.deb  401  Unauthorized

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

我现在不知道该怎么办。我该如何解决这个问题?

答案1

根据当前运行的 Ubuntu 版本,有两种方法。

(a)Ubuntu 16.04 LTS 为当前运行版本

您必须sources.list通过以下方式备份

sudo mv /etc/apt/sources.list ~/
sudo mv /etc/apt/sources.list.d/*.list ~/

然后填写主sources.list使用以下命令之一获取正确的 URL:

  • 清楚的sources.list代替

    cat <<EOF | sudo tee /etc/apt/sources.list
    deb http://archive.ubuntu.com/ubuntu/ xenial-backports main universe multiverse restricted
    deb http://archive.ubuntu.com/ubuntu/ xenial main universe multiverse restricted
    deb http://archive.ubuntu.com/ubuntu/ xenial-updates main universe multiverse restricted
    deb http://security.ubuntu.com/ubuntu/ xenial-security main universe multiverse restricted
    EOF
    
  • 使用add-apt-repository

    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ xenial-backports main universe multiverse restricted"
    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ xenial main universe multiverse restricted"
    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ xenial-updates main universe multiverse restricted"
    sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu/ xenial-security main universe multiverse restricted"
    

然后恢复升级到 18.04 LTS:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get purge ubuntu-advantage-tools --autoremove
sudo rm /etc/apt/sources.list.d/ubuntu-esm-infra.list
sudo do-release-upgrade

然后检查~/*.list以前版本的文件并将部分行移动到/etc/apt/sources.list

(b)Ubuntu 18.04 LTS 为当前运行版本

您必须sources.list通过以下方式备份

sudo mv /etc/apt/sources.list ~/
sudo mv /etc/apt/sources.list.d/*.list ~/

然后填写主sources.list使用以下命令之一获取正确的 URL:

  • 清楚的sources.list代替

    cat <<EOF | sudo tee /etc/apt/sources.list
    deb http://archive.ubuntu.com/ubuntu/ bionic-backports main universe multiverse restricted
    deb http://archive.ubuntu.com/ubuntu/ bionic main universe multiverse restricted
    deb http://archive.ubuntu.com/ubuntu/ bionic-updates main universe multiverse restricted
    deb http://security.ubuntu.com/ubuntu/ bionic-security main universe multiverse restricted
    EOF
    
  • 使用add-apt-repository

    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ bionic-backports main universe multiverse restricted"
    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ bionic main universe multiverse restricted"
    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ bionic-updates main universe multiverse restricted"
    sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu/ bionic-security main universe multiverse restricted"
    

然后安装所有必要的升级:

sudo apt-get purge ubuntu-advantage-tools --autoremove
sudo rm /etc/apt/sources.list.d/ubuntu-esm-infra.list

sudo apt-get update
sudo apt-get upgrade

然后检查以前版本的文件,并在替换时~/*.list部分移动行/etc/apt/sources.list赛尼尔仿生的

答案2

在 18.04 系统上(至少),查找一个/etc/apt/sources.list.d/ubuntu-esm-infra.list文件。该文件错误地列出了您需要付费的 ESM 更新源,并apt尽职尽责地尝试下载它们。

#我通过在两行前面分别添加一个来禁用这些源deb。文件现在如下所示:

# Written by ubuntu-advantage-tools
#deb https://esm.ubuntu.com/infra/ubuntu bionic-infra-security main
# deb-src https://esm.ubuntu.com/infra/ubuntu xenial-infra-security main

#deb https://esm.ubuntu.com/infra/ubuntu bionic-infra-updates main
# deb-src https://esm.ubuntu.com/infra/ubuntu xenial-infra-updates main

我认为删除该文件也行得通。

现在,当我再次更新系统时,使用我常用的更新命令:

$ sudo apt update && sudo apt autoremove && sudo apt upgrade

...该apt upgrade部分不会尝试下载那些未经授权的来源,并且升级能够完成!

答案3

当您使用 Ubuntu Pro 注册系统时,/etc/apt/auth.conf.d/90ubuntu-advantage会创建一个文件。此文件包含与您的 Ubuntu 帐户绑定的凭据,该凭据授予该系统检索 ESM 更新的权限。

我注册了一个系统,最初它没有问题,但经过几周的尝试从https://esm.ubuntu.com/出现 HTTP 401“未授权”错误。

我通过使用当前令牌值从https://ubuntu.com/pro/dashboard

这将使用/etc/apt/auth.conf.d/90ubuntu-advantage当前凭据重新生成文件。

  1. sudo pro 分离
  2. sudo pro 附加 TOKEN_VALUE_HERE
  3. sudo apt-get 更新

此时,我可以像以前一样应用更新(例如,通过,,)aptapt-getaptitude

相关内容