When you can rhc setup command, the username information gets stored in .openshift/express.conf file; hence the need to run it again when you want to switch the account.
Quite old question, but I use yet another solution which seems to be more comfortable (at least for me) - the environment variable OPENSHIFT_CONFIG.
The OPENSHIFT_CONFIG environment variable can be used to override the OpenShift configuration name (by default "express"). When set the operations performed with rhc refers to ~/.openshift/${OPENSHIFT_CONFIG}.conf (instead of ~/.openshift/express.conf).
To switch to the another OpenShift account the following could be used (Bash):
export OPENSHIFT_CONFIG=thenewone
rhc apps //apps on the new account
...
unset OPENSHIFT_CONFIG
rhc apps //apps on the default account
Verified with rhc 1.37.1, but should work with any version released after May 2013.
When you run the rhc setup command for the first time, the ~/.openshift/express.conf file is created, containing the settings for your initial server configuration. When you add another server, or run the rhc setup command again with the --server option, the ~/.openshift/servers.yml file is created, containing the settings for each server. You can edit this file to make any changes to the server configuration, and this takes precedence over the initial ~/.openshift/express.conf file.
rhc server use server.name.example.co
rhc server use Server_Nickname
On Windows, run these commands like and respond I did (denoted by < and >):
rhc setup -l login@domain.mail.com
Enter the server hostname: <openshift.redhat.com>
Password: <**********><Press Enter>
Generate a token now? (yes|no) y<Press Enter>
Generating an authorization token for this client ... lasts about 1 month
Saving configuration to C:\Users\UserName\.openshift\express.conf ... done
Your private SSH key file should be set as readable only to yourself. To make this change, run:
chmod 600 C:\Users\<Your Username>\.ssh\id_rsa
Your client tools are now configured.
Then you can use console commands for a long time with generated token for your OpenShift login.
You can configure multiple accounts using the server add command and then you can provide the server nickname in all subsequent commands using --server option. For example:
rhc server add -l <first_account> --nickname srv1 <first-server>
rhc server add -l <second_account> --nickname srv2 <second-server>
You may add options like -p, --use-authorized-tokens to suppress the prompts for password and token-generation. Also --insecured if required
rhc server use srv1
rhc server use srv2
Commands above perform some sort of initialization. Once two steps above are done you are ready to use your multiple accounts.
Now in your rhc commands you need to specify which server should be used. For example:
rhc app-show -n <domain> <app> --server srv1
Command above will show details of app in srv1. For srv2 you can run