CloudSSO is integrated with Alibaba Cloud CLI. You can log on to the CloudSSO user portal by using browsers or Alibaba Cloud CLI. If you use Alibaba Cloud CLI to access CloudSSO, you need to select an account in a resource directory and the required access configuration to access Alibaba Cloud resources. This topic describes how to use Alibaba Cloud CLI to access CloudSSO.
Background information
Alibaba Cloud CLI version 3.0.271 and later introduce a new CloudSSO credential type that streamlines the configuration process. This is the recommended method. The legacy method for older versions is still supported. You can check your current CLI version by running the aliyun version command.
For Alibaba Cloud CLI V3.0.271 and later
This method provides both an interactive and a non-interactive way to configure your CloudSSO credential. The interactive mode is ideal for getting started quickly, while the non-interactive mode is better suited for automation and scripting.
Interactive mode
Run the
aliyun configurecommand to start the configuration. You can use--profileto create multiple named profiles for different accounts or access configurations.aliyun configure --profile SSOProfile --mode CloudSSOWhen prompted, enter your user logon URL.
aliyun configure --profile SSOProfile --mode CloudSSO CloudSSO Sign In Url []: https://signin-******.alibabacloudsso.com/device/loginA browser window opens automatically. Follow the prompts to complete the logon process.
If a browser window does not open, copy the
SignIn urlandUser codefrom the CLI output and complete the process manually.Example prompt:
If the browser does not open automatically, use the following URL to complete the login process: SignIn url: https://signin-****.alibabacloudsso.com/device/code User code: *********After a successful logon, the CLI lists the Resource Directory accounts you can access. Select the account you want to use.
Now you can login to your account with SSO configuration in the browser. You have successfully logged in. Please choose an account: 1. <RD Management Account> 2. AccountName Please input the account number: 1Next, select one of the available access configurations.
Please choose an access configuration: 1. AccessConfiguration1 2. AccessConfiguration2 Please input the access configuration number: 2When prompted, set a default region.
Default Region Id []: cn-hangzhouUpon successful configuration, a
Configure Donemessage and a welcome banner are displayed.
Non-interactive mode
You can run the aliyun configure set command with the following options to configure a CloudSSO credential non-interactively.
Option | Description | Example |
profile | The name of the CloudSSO credential. It can contain letters, digits, and the following special characters: _ / + = . @ -. | SSOProfile |
mode | The credential type. Must be CloudSSO for this method. | CloudSSO |
cloud-sso-sign-in-url | The user logon URL. You can find this on the Overview page of the CloudSSO console. | https://signin-******.alibabacloudsso.com/device/login |
cloud-sso-account-id | The ID of the target Resource Directory account. You can find this on the Multi-account Permission Configuration page of the CloudSSO console. | 012345678910**** |
cloud-sso-access-config | The ID of the access configuration. You can find this on the Access Configuration page of the CloudSSO console. | ac-012345678910abcde**** |
region | The default region to use for CLI requests. Some cloud services are region-specific. For best results, set the default region to the one where your resources are located. | cn-hangzhou |
Example command:
aliyun configure set \
--profile SSOProfile \
--mode CloudSSO \
--cloud-sso-sign-in-url "https://signin-******.alibabacloudsso.com/device/login" \
--cloud-sso-account-id "012345678910****" \
--cloud-sso-access-config "ac-012345678910abcde****" \
--region "cn-hangzhou"aliyun configure set `
--profile SSOProfile `
--mode CloudSSO `
--cloud-sso-sign-in-url "https://signin-******.alibabacloudsso.com/device/login" `
--cloud-sso-account-id "012345678910****" `
--cloud-sso-access-config "ac-012345678910abcde****" `
--region "cn-hangzhou"After configuring a CloudSSO credential non-interactively, you must perform a one-time interactive logon to authorize the CLI. Run aliyun configure --profile <profileName> and complete the browser-based logon.