> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to work with the Nebius AI Cloud CLI on a Compute virtual machine

On a Compute virtual machine, you cannot log into the Nebius AI Cloud CLI with your user account, because it requires opening the web console in a browser. However, you can still use the Nebius AI Cloud CLI with a service account, in one of two ways:

* [Specify the service account on VM creation](#specifying-the-service-account-on-vm-creation)
* [Set up a profile for the service account on the VM](#setting-up-a-profile-for-the-service-account-on-the-vm)

For other environments without a browser, such as Docker containers and CI/CD runners, see [How to authenticate the Nebius AI Cloud CLI in environments without a browser](https://docs.nebius.com/cli/no-browser.md).

## Prerequisites

1. Make sure you are in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has the `admin` role within your tenant or project; for example, the default `admins` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.
2. [Create a service account](https://docs.nebius.com/iam/service-accounts/manage.md#create-a-service-account) and [add it to a group](https://docs.nebius.com/iam/authorization/groups/members.md#add-a-service-account) that has the [roles](https://docs.nebius.com/iam/authorization/roles.md) needed for your operations. Usually, this means adding it to at least the default `editors` group.

You do not need to install the Nebius AI Cloud CLI. It is preinstalled on every Compute VM.

## Specifying the service account on VM creation

When you [create a VM](https://docs.nebius.com/compute/virtual-machines/create.md#create-a-vm-cli), specify the service account ID in the VM specifications:

> [tab] CLI
>
> Add the `--service-account-id` parameter to the creation command:
>
> ```bash theme={null}
> nebius compute instance create \
>   ... \
>   --service-account-id <service_account_ID>
> ```

> [tab] Terraform
>
> Add the `service_account_id` parameter to the `nebius_compute_v1_instance` block in the configuration:
>
> ```hcl theme={null}
> resource "nebius_compute_v1_instance" "<VM_name>" {
>   service_account_id = "<service_account_ID>"
>   ...
> }
> ```

Once the VM is ready, you can connect to it and use the Nebius AI Cloud CLI without any additional setup. The authorization token is automatically fetched from `/mnt/cloud-metadata/token`.

## Setting up a profile for the service account on the VM

If you haven't specified a service account during VM creation, you can configure a Nebius AI Cloud CLI profile for that service account:

1. On your local machine, create an authorized key for the service account: [create a key pair](https://docs.nebius.com/iam/service-accounts/authorized-keys.md#creating-a-key-pair) and [upload the public key](https://docs.nebius.com/iam/service-accounts/authorized-keys.md#uploading-the-public-key).

2. Copy the private key to the VM:

   ```bash theme={null}
   scp <path_to_service_account_private_key> \
     <username>@<public_IP_address>:~/private.pem
   ```

3. Connect to the VM:

   ```bash theme={null}
   ssh <username>@<public_IP_address>
   ```

4. On the VM, create a profile for the service account by following the non-interactive flow in [How to set up the CLI for a service account](https://docs.nebius.com/cli/configure.md#how-to-set-up-the-cli-for-a-service-account). When saving the service account details to environment variables, set the private key path as follows:

   ```bash theme={null}
   export PRIVATE_KEY_PATH="~/private.pem"
   ```

5. Confirm that the CLI can authenticate as the service account:

   ```bash theme={null}
   nebius iam whoami
   ```

You can now use the Nebius AI Cloud CLI.
