Authenticating with the Yandex Cloud CLI as a federated user
You can use a federated account to work with Yandex Cloud if your company has an identity federation set up. In this case, no personal Yandex account is required.
Warning
To get authenticated in the CLI with a Yandex account, federated account, or local user account, you need a browser and a GUI.
If using the CLI on a server without a GUI, the recommended option is to authenticate with a service account.
If you cannot use a service account, authenticate via an SSH tunnel or X11 forwarding.
Tip
If your organization uses a proxy server to access Yandex Cloud, configure the CLI connection to the proxy server before running the yc init command.
If you do not have the Yandex Cloud CLI yet, install it.
To authenticate using a SAML-compatible identity federation:
-
Get your federation ID from your administrator.
-
Launch the profile creation wizard:
yc init --federation-id=<federation_ID>Note
If the server has no GUI or browser, you will get the following error:
ERROR: fill default credentials: federation id authentication is not supported on this system because the browser can not be openedAuthenticate using a service account. Alternatively, you can use an SSH tunnel or X11 forwarding.
-
Select the profile you want to set up authentication for or create a new one.
Welcome! This command will take you through the configuration process. Pick desired action: [1] Re-initialize this profile 'default' with new settings [2] Create a new profile -
The CLI prompts you to continue authentication in the browser. Press Enter to continue.
You are going to be authenticated via federation-id 'aje1f0hsgds3a********'. Your federation authentication web site will be opened. After your successful authentication, you will be redirected to 'https://console.yandex.cloud'. Press 'enter' to continue...On successful authentication, an IAM token will be saved in the profile. This IAM token will be used to authenticate each operation until the end of the token's lifetime (not more than 12 hours). After that, the CLI will once again prompt you to authenticate in the browser.
To extend the period during which you do not have to authenticate in the browser, use refresh tokens, which allow you to reissue IAM tokens without entering the browser. Do it by enabling refresh tokens at the organization level and initializing DPoP protection in the CLI.
-
Go back to the command line interface to finish creating the profile.
-
Select one of the clouds from the list of those you have access to:
Please select cloud to use: [1] cloud1 (id = aoe2bmdcvata********) [2] cloud2 (id = dcvatao4faoe********) Please enter your numeric choice: 2If there is only one cloud available, it will be selected automatically.
-
Select the default folder:
Please choose a folder to use: [1] folder1 (id = cvatao4faoe2********) [2] folder2 (id = tao4faoe2cva********) [3] Create a new folder Please enter your numeric choice: 1 -
To select the default availability zone for Compute Cloud, type
Y. To skip the setup, typen.Do you want to configure a default Yandex Compute Cloud availability zone? [Y/n] YIf you typed
Y, select the availability zone:Which zone do you want to use as a profile default? [1] ru-central1-a [2] ru-central1-b [3] ru-central1-d [4] Do not set default zone Please enter your numeric choice: 2 -
View your CLI profile settings:
yc config listResult:
federation-id: aje1f0hs6oja******** subject-id: ajea53egl28l******** cloud-id: b1g159pa15cd******** folder-id: b1g8o9jbt58******** compute-default-zone: ru-central1-b