[Yandex Cloud documentation](../../../index.md) > [Yandex Cloud Registry](../../index.md) > [Step-by-step guides](../index.md) > Managing artifacts > Debian artifact > Pushing a Debian package to a registry

# Pushing a Debian package to a registry

This guide describes how to push a [Debian package](../../concepts/artifacts/debian.md) to a [local registry](../../concepts/registry.md#local-registry).

To push a Debian package to a registry, you need the `cloud-registry.artifacts.pusher` [role](../../security/index.md#cloud-registry-artifacts-pusher) or higher.

{% list tabs group=debian_tools %}

- cURL {#curl} 

    1. Create the following environment variables depending on the authentication method:
       
       {% list tabs group=registry_auth %}
       
       - IAM token {#iam-token}
       
         1. Get an [IAM token](../../../iam/concepts/authorization/iam-token.md) for the [Yandex account](../../../iam/operations/iam-token/create.md) or [service account](../../../iam/operations/iam-token/create-for-sa.md) you are going to use for authentication.
         1. Create the `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` environment variables:
       
             ```bash
             export REGISTRY_USERNAME="iam"
             export REGISTRY_PASSWORD="<IAM_token>"
             ```
       
             Where:
       
             * `REGISTRY_USERNAME`: Authentication method.
             * `REGISTRY_PASSWORD`: Body of the previously obtained IAM token.
       
         {% note info %}
       
         The IAM token's [lifetime](../../../iam/concepts/authorization/iam-token.md#lifetime) is limited to 12 hours.
       
         {% endnote %}
       
       - API key {#api-key}
       
         1. [Create](../../../iam/operations/authentication/manage-api-keys.md#create-api-key) an API key for the [service account](../../../iam/concepts/users/service-accounts.md) you are going to use for authentication.
         1. Create the `REGISTRY_USERNAME` and `REGISTRY_PASSWORD` environment variables:
       
             ```bash
             export REGISTRY_USERNAME="api_key"
             export REGISTRY_PASSWORD="<API_key>"
             ```
       
             Where:
       
             * `REGISTRY_USERNAME`: Authentication method.
             * `REGISTRY_PASSWORD`: Body of the previously created [API key](../../../iam/concepts/authorization/api-key.md).
       
         {% note info %}
       
         The API key maximum [lifetime](../../../iam/concepts/authorization/api-key.md#scoped-api-keys) is set manually when you create the key.
       
         {% endnote %}
       
       {% endlist %}

    1. Run this HTTP request to push your package:

        ```bash
        curl \
          --url-query "dist=<distribution>" \
          --url-query "comp=<component>" \
          --user "${REGISTRY_USERNAME}:${REGISTRY_PASSWORD}" \
          --upload-file "<package>.deb" \
          "https://registry.yandexcloud.net/debian/<registry_ID>"
        ```

- dput {#dput}

  [dput](https://packages.debian.org/stable/dput) (Debian package upload tool) is a utility for pushing packages to Debian repositories.

  1. Select the authentication method:
     
     {% list tabs group=registry_auth %}
     
     - IAM token {#iam-token}
     
         Get an [IAM token](../../../iam/concepts/authorization/iam-token.md) for the [Yandex account](../../../iam/operations/iam-token/create.md) or [service account](../../../iam/operations/iam-token/create-for-sa.md) you are going to use for authentication.
     
         {% note info %}
     
         The IAM token's [lifetime](../../../iam/concepts/authorization/iam-token.md#lifetime) is limited to 12 hours.
     
         {% endnote %}
     
     - API key {#api-key}
     
         [Create](../../../iam/operations/authentication/manage-api-keys.md#create-api-key) an API key for the [service account](../../../iam/concepts/users/service-accounts.md) you are going to use for authentication.
     
         {% note info %}
     
         The API key maximum [lifetime](../../../iam/concepts/authorization/api-key.md#scoped-api-keys) is set manually when you create the key.
     
         {% endnote %}
     
     {% endlist %}

  1. Add the following registry configuration to the `/etc/dput.cf` file:

      ```ini
      [ycr]
      fqdn = registry.yandexcloud.net
      incoming = /debian/<registry_ID>/upload/
      login = <login>
      method = https
      allow_unsigned_uploads = 1
      ```

      Where:
      * `<registry_ID>`: Your registry ID.
      * `login`: Authentication method, `iam` or `api_key`.

  1. Upload the package:

      ```bash
      dput ycr <package>.changes
      ```

      Where `<package>.changes` is the package change file generated during the compilation.

{% endlist %}

#### Useful links {#see-also}

* [Configuring the APT package manager](installation.md)
* [Pulling a Debian package from a registry](pull.md)