Create a Local Deb Package Repository on Debian

PowerADM.com / Linux / Debian / Create a Local Deb Package Repository on Debian

In this article, we will show you how to quickly deploy your own local deb package repository and add the necessary packages to it.

Connect to the Debian host where you want to run the local repository and install the aptly package:

# apt install aptly

Create a config file /etc/aptly.conf (JSON format). You can use the default configuration, in which you only need to edit paths in rootDir and FileSystemPublishEndpoints:

{
 "rootDir": "/mnt/repo",
 "downloadConcurrency": 4,
 "downloadSpeedLimit": 0,
 "architectures": [],
 "dependencyFollowSuggests": false,
 "dependencyFollowRecommends": false,
 "dependencyFollowAllVariants": false,
 "dependencyFollowSource": false,
 "dependencyVerboseResolve": false,
 "gpgDisableSign": false,
 "gpgDisableVerify": false,
 "gpgProvider": "gpg",
 "downloadSourcePackages": false,
 "skipLegacyPool": true,
 "ppaDistributorID": "elk",
 "ppaCodename": "",
 "FileSystemPublishEndpoints": {
  "elkrepo": {
   "rootDir": "/var/www/aptly",
   "linkMethod": "symlink",
   "verifyMethod": "md5"
  }
 },
 "enableMetricsEndpoint": false
}

Create directories:

# mkdir -p /mnt/repo /var/www/aptly

In this example, we will create a repository for Debian 11 Bullseye :

# aptly repo create -distribution="bullseye" elk

Now download the deb package you want to add to your local repository. In my example, this will be the filebeat-8.4.3-amd64.deb package, which I downloaded from the Elastic website (https://www.elastic.co/downloads/beats/filebeat).

# wget -q --show-progress https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.4.3-amd64.deb

Copy the deb package to the server and add it to the repository:

# aptly repo add elk ~/filebeat-8.4.3-amd64.deb

Create a GPG key for the repository:

# gpg --default-new-key-algo rsa4096 --gen-key --keyring pubring

Real name: elkrepo

Publish the repository with this key:

# aptly publish repo elk

You can immediately export the public key:

# gpg --export --armor > /mnt/repo/public/elkrepo.asc

Now you need to run any web server on the host and run a website with target /var/www/aptly directory. You can use aptly itself as a web server (default 8080):

# aptly serve

aptly - create local deb repository

Aptly will create and publish the /mnt/repo/public directory. Run a browser and connect your to the repository host server on port 8080. View the contents of the repository along with the ПЗПkey.

It remains to connect your local repository on Debian clients. Create file /etc/apt/sources.list.d/elk_repo.list:

deb http://192.168.55.20:8080 bullseye main

Update the packages and you can now install filebeat from your local deb repository:

# apt update && apt install filebeat
Leave a Reply

Your email address will not be published. Required fields are marked *