This README provides instructions for setting up Aptly on Arch Linux and configuring it to create and manage APT repositories for Debian-based systems, with integration to AWS S3 for hosting.
- Prerequisites
- Installation on Arch Linux
- Aptly Configuration
- GPG Key Setup
- Creating and Managing APT Repositories
- Publishing to S3
- Client-side Configuration (for Debian-based systems)
- Troubleshooting
- Arch Linux system
- sudo privileges
- AWS account with S3 access
-
Update your system:
sudo pacman -Syu
-
Install necessary dependencies:
sudo pacman -S base-devel git go
-
Clone the Aptly repository:
git clone https://github.com/aptly-dev/aptly.git
-
Build and install Aptly:
cd aptly make install
-
Verify the installation:
aptly version
-
Create the Aptly configuration directory:
sudo mkdir -p /etc/aptly
-
Create and edit the Aptly configuration file:
sudo nano /etc/aptly/aptly.conf
-
Add the following configuration, adjusting as necessary:
{ "rootDir": "/var/lib/aptly", "downloadConcurrency": 4, "downloadSpeedLimit": 0, "architectures": ["amd64"], "dependencyFollowSuggests": false, "dependencyFollowRecommends": false, "dependencyFollowAllVariants": false, "dependencyFollowSource": false, "dependencyVerboseResolve": false, "gpgDisableSign": false, "gpgDisableVerify": false, "downloadSourcePackages": false, "skipContentsPublishing": false, "S3PublishEndpoints": { "invinsense": { "region": "us-east-2", "bucket": "invinsense", "prefix": "4.x/apt/", "storageClass": "STANDARD", "encryptionMethod": "AES256" } } }
Note: Ensure you have configured AWS credentials securely using AWS CLI configuration, IAM roles, or environment variables. Do not include AWS access keys in this file.
-
Generate a GPG key:
gpg --full-generate-key
-
List your keys and note the ID of the newly created key:
gpg --list-keys
-
Export the public key:
gpg --armor --export 'Your Key ID' > public-key.gpg
-
Upload the public key to S3:
aws s3 cp public-key.gpg s3://invinsense/4.x/apt/public-key.gpg
-
Create a new repository:
aptly repo create -distribution=stable -component=main invinsense-repo
-
Add Debian packages to the repository:
aptly repo add invinsense-repo /path/to/your/package.deb
Note: Ensure you're adding
.deb
packages for Debian-based systems. -
Create a snapshot of the repository:
aptly snapshot create invinsense-snap from repo invinsense-repo
-
Publish the snapshot to S3:
aptly publish snapshot -architectures="amd64" -distribution="stable" -gpg-key="Your Key ID" invinsense-snap s3:invinsense:
-
To update the repository later:
aptly publish update stable s3:invinsense:
For Debian-based clients to use your repository: Based on the error messages you're encountering, it seems there are a few issues we need to address to get the repository working correctly. Let's go through this step-by-step:
-
The GPG key issue: The system is unable to verify the repository because it doesn't have the correct public key. The error message shows the key ID: F89036D491DD8FC5
-
The attempt to add the key using apt-key failed: This is because apt-key is deprecated, and the keyserver didn't have the key we're looking for.
Here's what we can do to resolve these issues:
- First, let's try to download the public key directly from the S3 bucket and add it to the apt trusted keys:
wget -qO- https://invinsense.s3.us-east-2.amazonaws.com/4.x/apt/public-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/invinsense-archive-keyring.gpg
- Now, let's modify the sources list entry to use the new keyring file:
echo "deb [signed-by=/usr/share/keyrings/invinsense-archive-keyring.gpg] https://invinsense.s3.us-east-2.amazonaws.com/4.x/apt/ stable main" | sudo tee /etc/apt/sources.list.d/invinsense-repo.list
- After these changes, try updating again:
sudo apt-get update
If you still encounter issues, we might need to verify a few things:
- Check if the public key was correctly downloaded and added:
ls -l /usr/share/keyrings/invinsense-archive-keyring.gpg
- If the file exists but you're still getting errors, we might need to check the contents of the public key. Let's view its contents:
gpg --no-default-keyring --keyring /usr/share/keyrings/invinsense-archive-keyring.gpg --list-keys
This should show you the key ID. Make sure it matches the one in the error message (F89036D491DD8FC5).
- If all else fails, you might need to contact the repository maintainer to ensure that the public key available in the S3 bucket is correct and up-to-date.
Let me know the results of these steps, and we can troubleshoot further if needed.
-
If clients encounter GPG key errors, verify the key was correctly imported:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 'Your Key ID'
-
For S3 access issues, verify your AWS credentials and S3 bucket permissions.
-
If packages are not found, ensure the S3 paths in your Aptly configuration and sources.list are correct.
-
For detailed logs on Debian-based clients, check
/var/log/apt/term.log
.
Remember to keep your AWS credentials and GPG keys secure. Never share them publicly or include them in configuration files. If you suspect your credentials have been compromised, rotate them immediately through the AWS IAM console.
Adding xdr-manager Package to Existing Aptly-managed APT Repository
Prepare the Debian package
xdr-manager.deb
package ready.Add the package to the Aptly repository
Create a new snapshot
Publish the new snapshot
Verify the upload
Update client machines
On Debian-based machines using this repository:
Test the new package
Remember to replace
path/to/xdr-manager.deb
with the actual path to your Debian package file.