Skip to main content
To authenticate as a service account and perform operations on its behalf, use an authorized key pair.

Prerequisites

  1. Make sure you are in a group that has the admin role within your tenant or project; for example, the default admins group. You can check this in the Administration → IAM section of the web console.
  2. Create a new service account if needed.

Creating a key pair

If you are using the CLI, this step is optional. If you use the nebius iam auth-public-key generate command in the next step, the CLI creates the key pair for you.
Create a key pair on your local machine:
This command creates the public.pem and private.pem key files in your local directory where you run the command.

Uploading the public key

To upload an authorized key with Terraform or one of the SDKs, the provider or SDK must already be authenticated with an existing authorized key. You cannot upload the first authorized key for a service account using Terraform or an SDK. If you already have an authorized key, for example, one created with the CLI, proceed to update the configuration to use your existing authorized key with Terraform or the SDK.
  1. In the web console, go to Administration → IAM.
  2. Open the Service accounts tab.
  3. Open the page of the required service account.
  4. Click Upload authorized key.
  5. Click Attach file and then select public.pem.
  6. (Optional) Set an expiration date.
  7. Click Upload key.
The key is displayed on the Authorized keys tab.

Updating the configuration

Update your configuration to use the authorized key you created:
If you used the web console to upload the public key, you do not need to update any additional configuration.
Create a new CLI profile:
  1. Get the ID of the project that you want to work in and save it to an environment variable:
  2. Initialize the Nebius AI Cloud CLI configuration:
  3. Check that your new profile has been created and set as default:
Now you can run Nebius AI Cloud CLI commands on behalf of the service account. To do this, add --profile <service_account_profile_name> to the commands.

Listing expiring keys

After an authorized key expires, you can’t use it to authenticate as the service account. To find the keys that you need to replace soon, list the keys that expire within the next seven days, across all service accounts in your project.
List the expiring keys, sorted by expiration date:
For each key, the output contains the following fields:
  • id: ID of the key.
  • service_account_id: ID of the service account that the key belongs to.
  • expires_at: Date and time when the key expires.
To adjust the command:
  • To change the period, replace 7 in 7 * 86400 with another number of days.
  • To list keys in a project other than the one saved in your CLI profile, add --parent-id <project_ID> to the command.
The list doesn’t include keys that have already expired or keys without an expiration date. If the list is empty, no keys expire within the next seven days. To replace an expiring key, upload a new public key and update your configuration to use it.