Configuring the APT package manager
This guide describes how to connect the APT package manager
Preparing a GPG key
A GPG key is required for a registry with signed metadata. The signature allows clients to verify the authenticity of packages.
-
Generate a GPG key using GnuPG
:gpg --full-generate-keyWhen prompted for
passphrase, leave this field empty. -
Retrieve the ID of the GPG key you created:
gpg --list-secret-keys --keyid-format=longResult:
/home/user/.gnupg/secring.gpg ------------------------------ sec 4096R/<GPG_key_ID> 2024-01-01 [expires: 2026-01-01] uid User Name <user@example.com> ssb 4096R/XXXXXXXXXXXXXXXX 2024-01-01 -
Export the secret part of the GPG key:
gpg --armor --export-secret-keys <GPG_key_ID> -
Save the secret part of the GPG key in a Yandex Lockbox secret under the
gpg_secret_key_valuekey:yc lockbox secret create \ --name <secret_name> \ --payload "[{'key': 'gpg_secret_key_value', 'text_value': '$(gpg --armor --export-secret-keys <GPG_key_ID>)'}]" -
Grant access to the secret contents to the Cloud Registry service agent by assigning it the
lockbox.payloadViewerrole for this secret:yc lockbox secret add-access-binding \ --id <secret_ID> \ --role lockbox.payloadViewer \ --agent cloud-registry:control-plane \ --cloud-id <cloud_ID> -
Save the public part of the GPG key. Registry users will need this value:
gpg --armor --export <GPG_key_ID> > public-key.asc
Configuring APT
Local registry
-
Add the registry to the
APTsources list:Registry with signed metadataRegistry with unsigned metadata-
Copy the public GPG key to the directory with APT trusted keys:
cp /path/to/public-key.asc /usr/share/keyrings/ycr-pub.ascWhere
/path/to/public-key.ascis the path to the public GPG key file. -
Add the registry to the
APTsources list:echo "deb [signed-by=/usr/share/keyrings/ycr-pub.asc] https://registry.yandexcloud.net/debian/<registry_ID> <distribution> <component>" \ >> /etc/apt/sources.list
Add a registry with
trusted=yes:echo "deb [trusted=yes] https://registry.yandexcloud.net/debian/<registry_ID> <distribution> <component>" \ >> /etc/apt/sources.list -
-
Add authentication data to the
/etc/apt/auth.conffile:IAM tokenAPI keymachine https://registry.yandexcloud.net/debian/<registry_ID> login iam password <IAM_token>machine https://registry.yandexcloud.net/debian/<registry_ID> login api_key password <API_key>
Remote registry
Public source
-
Install the package with the distribution public keys:
DebianUbuntuRun this command:
sudo apt install debian-archive-keyringThe key will be available at
/usr/share/keyrings/debian-archive-keyring.gpg.Run this command:
sudo apt install ubuntu-keyringThe key will be available at
/usr/share/keyrings/ubuntu-archive-keyring.gpg. -
Add the registry to the
APTsources list:echo "deb [signed-by=<path_to_key>] https://registry.yandexcloud.net/debian/<registry_ID> <distribution> <component>" \ >> /etc/apt/sources.listWhere:
<path_to_key>: Path to the distribution key file, e.g.,/usr/share/keyrings/debian-archive-keyring.gpgor/usr/share/keyrings/ubuntu-archive-keyring.gpg.<registry_ID>: Registry ID.<distribution>: Distribution, e.g.,bookworm,bullseye, orfocal.<component>: Repository component, e.g.,main.
-
Add authentication data to the
/etc/apt/auth.conffile:IAM tokenAPI keymachine https://registry.yandexcloud.net/debian/<registry_ID> login iam password <IAM_token>machine https://registry.yandexcloud.net/debian/<registry_ID> login api_key password <API_key>
Custom source
-
Add the registry to the
APTsources list:Source signed with a GPG keySource not signed with a GPG key-
Save it to the trusted keys directory:
cp /path/to/upstream-public-key.asc /usr/share/keyrings/upstream-pub.ascWhere
/path/to/upstream-public-key.ascis the path to the public key file of the source repository (upstream). -
Add the registry to the
APTsources list:echo "deb [signed-by=/usr/share/keyrings/upstream-pub.asc] https://registry.yandexcloud.net/debian/<registry_ID> <distribution> <component>" \ >> /etc/apt/sources.list
Specify the
trusted=yesparameter for APT to accept unauthenticated packages:echo "deb [trusted=yes] https://registry.yandexcloud.net/debian/<registry_ID> <distribution> <component>" \ >> /etc/apt/sources.list -
-
Add authentication data to the
/etc/apt/auth.conffile:IAM tokenAPI keymachine https://registry.yandexcloud.net/debian/<registry_ID> login iam password <IAM_token>machine https://registry.yandexcloud.net/debian/<registry_ID> login api_key password <API_key>
Warning
The APT package manager does not inject environment variables into configuration files. To protect your credentials, restrict access to /etc/apt/auth.conf at the OS level.