Apt repository gives me "400 Bad Request" when running `apt-get update` with authorization


#1

I’ve just added my first my first apt repo.
Uploading artefacts is working great, but I’m struggeling to add the repo to apt. Right now it needs a user for downloading the files. Doing that manually works great too. And I know how to add auth info to apt, which is working as well (if I change the PW I get a 401 instead of the other error I’m about to describe).

Now when I add it apt and run apt-get update, I get this error message from apt:

E: Failed to fetch https://repo.mycompany.com/repository/apt-develop/dists/buster/InRelease  400  Bad Request [IP: 10.128.1.101 443]
E: The repository 'https://repo.mycompany.com/repository/apt-develop buster InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

I checked the Nexus logs but there was nothing to be found either.

What can I do?


Update:

I just double checked some things. When I allow anonymous users to access the repo and remove the auth from the config then it works.
So Nexus isn’t liking something about the request when auth is used.


#2

Hi, Yannick!
Thank you for your question.
Would you please provide information about how you set up the apt client to pass your credentials?

Regards,
Anatoliy


#3

I created the file /etc/apt/auth.conf.d/mycomany.conf and it has this content:

machine repo.mycompany.com
login apt
password 0urSup3rS3cr37P@$$w0rd!

Changing any of this will change the error from a 400 Bad Request to a 401 Unauthorized, so I’m certain that it is configured correctly.


#4

Would you please try to set credentials in the source.list directly? e.g.
deb http://apt:0urSup3rS3cr37P@$$w0rd!@repo.mycompany.com/repository/apt-develop buster main


#5

A 400 response won’t have anything to do with authentication, it means that an invalid request was received. Have you checked the request.log to see what request is returning the 400 response?


#6

Just tried with docker image namely:

  1. docker run --name=“ubuntu19.10” -it ubuntu:19.10
  2. Nexus repository 3.18
  3. config with your example /etc/apt/auth.conf.d/mycomany.conf
    apt-get update and further actions work fine.

Indeed would be great if you provide some additional information about the environment, some logs, are you behind the proxy e.t.c.


#7

Alright. I managed to find the issue.
The password contained some special chars that caused issues apparently. Changing it to one without those made it work.

From the looks of it either _ or / was causing issues here. But can’t tell for sure.


#8

Great! Thanks for update!