Downloading files (not from repo) from private GitLab server

Viewed 177

I need to get a file from a private GitLab in a script (actually a Yocto recipe, if it matters).

Issuing: https://gitlab2server.com/api/v4/projects/53/packages/generic/paCKAGE/21.08.16/FILE.tar.xz on a browser works fine, but wget <same URL> fails with a "401 Unauthorized".

I can get around the problem with curl --header "PRIVATE_TOKEN: xxxx" ... but that means encoding my private token into a shell script which doesn't seem right.

To access a regular git repo I can use git clone git:... and it works because of the uploaded keys.

Using the equivalent scp gitlab2server.com:/api/v4/... . does not work because "Permission denied (publickey).".

What is the right way to do this?

Ideally I would need to have a ssh (actually scp, of course) access using pre-shared keys to access the files. I would hate to put large binaries into the git repo just to be able to access them.

1 Answers

The only way to authenticate with the GitLab API (including the Package API here) is using a personal access token, or the CI_JOB_TOKEN environment variable if running within GitLab CI/CD. CI_JOB_TOKEN is one of the Predefined Variables available to every CI/CD Pipeline Job and holds a non-admin token.

Related