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
To configure APT, add:
- Registry to the APT sources list.
- Authentication data to the
/etc/apt/auth.conffile.
Your method of adding a registry to the APT sources list will vary depending on registry format and source type.
Adding a registry to the APT sources list
Local registry
-
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
Remote registry
-
Install the package with the distribution public keys:
-
For Debian:
sudo apt install debian-archive-keyringThe key will be available at
/usr/share/keyrings/debian-archive-keyring.gpg. -
For Ubuntu:
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.
-
Save a GPG key 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=yes parameter for APT to accept unauthenticated packages:
echo "deb [trusted=yes] https://registry.yandexcloud.net/debian/<registry_ID> <distribution> <component>" \
>> /etc/apt/sources.list
Adding authentication credentials
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.
-
Select the authentication method:
IAM tokenAPI keyGet an IAM token for the Yandex account or service account you are going to use for authentication.
Note
The IAM token's lifetime is limited to 12 hours.
Create an API key for the service account you are going to use for authentication.
When creating a key, specify its scope:
yc.cloud-registry.artifacts.pull: To pull artifacts from the registry.yc.cloud-registry.artifacts.push: To push artifacts to the registry.
Note
The API key maximum lifetime is set manually when you create the key.
-
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>
Useful links
Scope is an API key parameter that restricts the key's use to specific operations in addition to the service account's access permissions. For details, see API keys with scope and validity limits.