Setting up an OpenShift account using rhc
In the Installing the OpenShift rhc command-line client recipe, you learned how to install the rhc
command-line client. After installation, the first operation you have to perform is to set up the OpenShift account. In this recipe, you will learn how to set up your account using rhc
.
Getting ready
To complete this recipe, you will need to have rhc
installed on your machine. Refer to the Installing the OpenShift rhc command-line client recipe for instructions.
How to do it…
To set up an OpenShift account, open a command-line terminal and run the following command:
$ rhc setup
How it works…
Before you can use the rhc
client to work with OpenShift, you have to set up the account.
The setup
command does the following:
- It first asks you to provide your OpenShift credentials to authenticate with openshift.redhat.com.
- After successful authentication,
rhc
asks whether it should create an authorization token. An authorization token allows you to access the OpenShift server without entering the password with every command. It stores the token in the.openshift
folder under the user'shome
directory. By default, the token is valid for 30 days, which means that after this you have to authenticate it again. - Next, the
setup
command creates a file calledexpress.conf
in the.openshift
folder under the user'shome
directory. Theexpress.conf
file stores the basic configuration required byrhc
such as the OpenShift server location, your OpenShift username, and whether or not to create and use authorization tokens. - If no SSH key exists in the
.ssh
folder at~/.ssh
, then therhc
setup
command will generate a new key pair using thessh-keygen
utility. - After generating the new SSH key pair,
rhc
will upload the public SSH key to the OpenShift server. OpenShift copies the public key into an authorization file on the application gear calledauthorized_keys
at~/.ssh/authorized_keys
. In the Uploading SSh keys using the web console recipe, you uploaded the public SSH key using the web console. It will prompt you to provide the name of the key or use the default name generated by thesetup
command. - Next,
rhc
checks if Git has been installed. Therhc setup
command will run a simple check against your local configuration and credentials to confirm that the configurations have been completed. It will also run a series of tests to check whetherssh
has been configured properly and whether your system can communicate with OpenShift servers. - Finally,
rhc
asks the user to create a domain if one is not already created. In the Creating OpenShift domains using the web console recipe, you created the domain using the web console.
There's more…
You can run the rhc
setup
command anytime while working with OpenShift. Every time you run the rhc
setup
command, it will use the configuration properties defined in the express.conf
file. If you want to generate a new, clean configuration, you can use the --clean
option. This will run the setup
command again, ignoring any saved configuration options stored in express.conf
:
$ rhc setup --clean
See also
- The Enabling the autocomplete feature in an rhc command-line client recipe
- The Viewing the account details using rhc recipe
- The Specifying a different OpenShift server hostname recipe