Error "401 Unauthorized" with apt install on Surface Book 2

I’m trying to set up my Surface Book 2 using Ubuntu 20.04.

I first used following commands:

wget -qO - https://raw.githubusercontent.com/linux-surface/linux-surface/master/pkg/keys/surface.asc | gpg --dearmor | sudo dd of=/etc/apt/trusted.gpg.d/linux-surface.gpg
echo "deb [arch=amd64] https://pkg.surfacelinux.com/debian release main" | sudo tee /etc/apt/sources.list.d/linux-surface.list
sudo apt update
sudo apt install linux-image-surface linux-headers-surface iptsd libwacom-surfacei

With the last command, I get the following:

Err:1 https://pkg.surfacelinux.com/debian release/main amd64 libwacom-surface amd64 1.12-2
  401  Unauthorized [IP: 185.199.108.133 443]
Err:2 https://pkg.surfacelinux.com/debian release/main amd64 iptsd amd64 0.5-1
  401  Unauthorized [IP: 185.199.108.133 443]
Err:3 https://pkg.surfacelinux.com/debian release/main amd64 linux-headers-surface amd64 5.14.16-surface-1
  401  Unauthorized [IP: 185.199.108.133 443]
Err:4 https://pkg.surfacelinux.com/debian release/main amd64 linux-image-5.14.16-surface amd64 5.14.16-surface-1
  401  Unauthorized [IP: 185.199.108.133 443]
E: Failed to fetch https://objects.githubusercontent.com/github-production-release-asset-2e65be/139604852/86019e52-7bfa-4bc6-8cc1-52147027aee6?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A/20211106/us-east-1/s3/aws4_request&X-Amz-Date=20211106T131450Z&X-Amz-Expires=300&X-Amz-Signature=9b44d56c807e04d58c36fc33d5a6ad4ae1f74fee6431e763897fd886cb3a575d&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=139604852&response-content-disposition=attachment; filename=libwacom-surface_1.12-2_amd64.deb&response-content-type=application/octet-stream  401  Unauthorized [IP: 185.199.108.133 443]
E: Failed to fetch https://objects.githubusercontent.com/github-production-release-asset-2e65be/261858706/88ea66fa-8b1d-45dd-96a0-004ddaaa2281?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A/20211106/us-east-1/s3/aws4_request&X-Amz-Date=20211106T131634Z&X-Amz-Expires=300&X-Amz-Signature=2051bebe2fe503c967b59d3657a56f9b668aaf1718c448570958f5acf7f7dfbd&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=261858706&response-content-disposition=attachment; filename=iptsd_0.5-1_amd64.deb&response-content-type=application/octet-stream  401  Unauthorized [IP: 185.199.108.133 443]
E: Failed to fetch https://objects.githubusercontent.com/github-production-release-asset-2e65be/155009767/5e6532eb-2738-49cf-aac9-2f6b5669e2c7?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A/20211106/us-east-1/s3/aws4_request&X-Amz-Date=20211106T131450Z&X-Amz-Expires=300&X-Amz-Signature=365eaaa7166dce0ed9871d0dda23f3e215e6faf76c076d9bb2dbcfdd38b2bdc1&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=155009767&response-content-disposition=attachment; filename=linux-headers-surface_5.14.16-surface-1_amd64.deb&response-content-type=application/octet-stream  401  Unauthorized [IP: 185.199.108.133 443]
E: Failed to fetch https://objects.githubusercontent.com/github-production-release-asset-2e65be/155009767/5538f486-10ef-4ba5-9136-f43f5938c538?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A/20211106/us-east-1/s3/aws4_request&X-Amz-Date=20211106T131450Z&X-Amz-Expires=300&X-Amz-Signature=ead5fed4643556504c56e282292cdb31b8e378981b62011d600c0fe9b4cb1f8c&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=155009767&response-content-disposition=attachment; filename=linux-image-5.14.16-surface_5.14.16-surface-1_amd64.deb&response-content-type=application/octet-stream  401  Unauthorized [IP: 185.199.108.133 443]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

I tried setting some archives in sources.list to

http://security.ubuntu.com/ubuntu/

and I’m really stuck right now. I also tried

sudo apt-get update
sudo apt-get update --fix-missing

Solution 1:

Run the following three commands:

sudo add-apt-repository ppa:tj/bugfixes
sudo apt-get update
sudo apt install apt apt-utils

Then try your last command again. It should install correctly.

Taken from this thread https://github.com/linux-surface/linux-surface/issues/625 linked by @pyoor. The issue seems to be caused by a bug in apt, which is fixed for ubuntu 20.04 in @iam-TJ's package.

Solution 2:

This worked perfectly for my Surface Book 2.

After adding @iam-TJ's package as above, to complete the upgrade:

sudo apt update --fix-missing
sudo apt upgrade

The last step will do the actual work of performing the installation.