5

After logging in IBMCloud with account(say account-1) by using CLI, how to switch to another account(say account-2) without logging out?

commands: ibmcloud login --sso, then select account-1.

Does IBMCloud CLI have a command for account switching?

chloe ibm
  • 51
  • 1
  • 2

2 Answers2

9

This is how we switch an account via CLI at IBM cloud

login to account

$ ibmcloud login -a cloud.ibm.com --sso
$ ibmcloud account list
$ ibmcloud target -c <<accpunt_id>>

example:
$ ibmcloud target -c 0XXXXXXXXXXXXXXXXXXXXXXXX

Targeted account IPOPS Test - PROD (0XXXXXXXXXXXXXXXXXXXXXXXX) <-> 20XXXX2



API endpoint:      https://cloud.ibm.com

Region:            us-south

User:              g***l@xxx.com

Account:           g account - (XXXXXXXXXXXXXXXXXXXXX) <-> 2041792

Resource group:    No resource group targeted, use 'ibmcloud target -g RESOURCE_GROUP'

CF API endpoint:
Org:
Space:
Ente
  • 2,301
  • 1
  • 16
  • 34
2

You can use the following command to switch accounts, assuming you know the Account ID/GUID of the account where you'd like to switch:

ibmcloud target -c ACCOUNT_ID