'How to get packages on Ubuntu machine from local artifactory server

what is the issue

i have setup the local artifactory server to download all the debian/ubuntu packages.

here are my remote repos :

repo key : op.archive.ubuntu.com , URL : http://us.archive.ubuntu.com/ubuntu/
repo key : op.security.ubuntu.com, url : http://security.ubuntu.com/ubuntu

and this mapped to virtual repo :

https://<<url>>/artifactory/op-deb-debian-virtual

now, in the ubuntu machine, here are the contents of /etc/apt/sources.list file

deb https://<<url>>/artifactory/op-deb-debian-virtual/ stretch main contrib non-free
deb https://<<url>>/artifactory/op-deb-debian-virtual/ stretch-updates main contrib non-free

but now, when i am running apt-get update command, it is failing with the following error. not able to understand , is the issue with artifactory server , sources.list OR something else

what is the error

Err:5 https://<>/artifactory/op2-deb-debian-virtual stretch/main amd64 Packages 401 Unauthorized Ign:6 https://<>/artifactory/op2-deb-debian-virtual stretch/main i386 Packages Ign:7 https://<>/artifactory/op2-deb-debian-virtual stretch/main all Packages Ign:8 https://<>/artifactory/op2-deb-debian-virtual stretch/main Translation-en_US Ign:9 https://<>/artifactory/op2-deb-debian-virtual stretch/main Translation-en Ign:10 https://<>/artifactory/op2-deb-debian-virtual stretch/contrib amd64 Packages Ign:11 https://<>/artifactory/op2-deb-debian-virtual stretch/contrib i386 Packages Ign:12 https://<>/artifactory/op2-deb-debian-virtual stretch/contrib all Packages Ign:13 https://<>/artifactory/op2-deb-debian-virtual stretch/contrib Translation-en_US Ign:14 https://<>/artifactory/op2-deb-debian-virtual stretch/contrib Translation-en Ign:15 https://<>/artifactory/op2-deb-debian-virtual stretch/non-free amd64 Packages Err:20 https://<>/artifactory/op2-deb-debian-virtual stretch-updates/main amd64 Packages 401 Unauthorized Ign:21 https://<>/artifactory/op2-deb-debian-virtual stretch-updates/main i386 Packages Ign:22 https://<>/artifactory/op2-deb-debian-virtual stretch-updates/main all Packages Ign:23 https://<>/artifactory/op2-deb-debian-virtual stretch-updates/main Translation-en_US Ign:24 https://<>/artifactory/op2-deb-debian-virtual stretch-updates/main Translation-en Ign:25 https://<>/artifactory/op2-deb-debian-virtual stretch-updates/contrib amd64 Packages Ign:26 https://<>/artifactory/op2-deb-debian-virtual stretch-updates/contrib i386 Packages Ign:27 https://<>/artifactory/op2-deb-debian-virtual stretch-updates/contrib all Packages Ign:28 https://<>/artifactory/op2-deb-debian-virtual stretch-updates/contrib Translation-en_US Ign:29 https://<>/artifactory/op2-deb-debian-virtual stretch-updates/contrib Translation-en Ign:30 https://<>/artifactory/op2-deb-debian-virtual stretch-updates/non-free amd64 Packages Reading package lists... Done W: The repository 'https://<>/artifactory/op2-deb-debian-virtual stretch Release' does not have a Release file. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use. N: See apt-secure(8) manpage for repository creation and user configuration details. W: The repository 'https://<>/artifactory/op2-deb-debian-virtual stretch-updates Release' does not have a Release file. N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use. N: See apt-secure(8) manpage for repository creation and user configuration details. E: Failed to fetch https://<>/artifactory/op2-deb-debian-virtual/dists/stretch/main/binary-amd64/Packages 401 Unauthorized E: Failed to fetch https://<>/artifactory/op2-deb-debian-virtual/dists/stretch-updates/main/binary-amd64/Packages 401 Unauthorized E: Some index files failed to download. They have been ignored, or old ones used instead.

what is expected

after adding proper artifactory url in the sources.list, should work. thats what i did , still not working

please suggest

update 1

the previous issue resolved. it was due to the permission issue. i used username and password (base 64 format) and it worked . but now the issues is with 403 forbidden

exact error

E: Failed to fetch https://artifactory-na.honeywell.com/artifactory/op2-deb-debian-virtual/dists/xenial/main/binary-amd64/Packages  403  Forbidden
E: Failed to fetch https://artifactory-na.honeywell.com/artifactory/op2-deb-debian-virtual/dists/xenial-updates/main/binary-amd64/Packages  403  Forbidden
E: Failed to fetch https://artifactory-na.honeywell.com/artifactory/op2-deb-debian-virtual/dists/xenial-backports/main/binary-amd64/Packages  403  Forbidden
E: Failed to fetch https://artifactory-na.honeywell.com/artifactory/op2-deb-debian-virtual/dists/xenial-security/main/binary-amd64/Packages  403  Forbidden
E: Some index files failed to download. They have been ignored, or old ones used instead.

for me the line ,

E: Some index files failed to download. They have been ignored, or old ones used instead

is triggering. is it something like , some mirror is down ?? how can i fix this ... ? even if mirror is down, i feel that mirror or apt-get should take care that ??

please suggest



Solution 1:[1]

The most likely cause for a 403 in this scenario is that the user used in the sources.list does not have 'Deploy' permissions on the Remote repositories (op.archive.ubuntu.com and op.security.ubuntu.com)

Solution 2:[2]

I was getting a 403 (Forbidden) response because I was running as root. Perhaps the user name is passed to the server, and then the server requires a password if it's root.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 eranb
Solution 2 Serge Rogatch