How to Install Oracle Cloud CLI Tool

I’m getting really into OCI (Oracle Cloud Infrastructure) CLI (Command Line Interface). It’s really cool to be able query and manipulate the Oracle Cloud Infrastructure resources. First, let’s see how we can install it.


Copy the following command and paste it in your terminal.

$ bash -c "$(curl -L"

Pretty much all default values will do when prompted to enter information and the install is complete when you execute the next command.

$ source ~/.bashrc # ~/.bash_profile if macOS.

Depending on your environment, have your shell read the correct source.


Enter the following command to start to configure.

$ oci setup config

You will be prompted to choose where you want to store the configuration file for OCI CLI. I usually leave it at the default location, so simply hit enter (return) here.

Enter a location for your config [/home/amaterasu48/.oci/config]:

Now you will be prompted to enter user OCID. First login to OCI UI and click the Profile menu icon. And then select User Settings. By the way, OCID is resource identifier throughout Oracle Cloud Infrastructure. For more details, please refer to this documentation.

Then copy your OCID to your clipboard by clicking Copy link.

Back in your terminal, paste the copied user OCID and then hit enter.

Enter a user OCID: [Paste your user OCID here]

Next, you will be prompted to enter tenancy ID. Tenancy is equivalent to account. Click Profile -> Tenancy: [your tenancy name]

Now click Copy link to copy the Tenancy OCID.

Back in your terminal, paste the copied Tenancy OCID and then hit enter.

Enter a tenancy OCID: [Paste your tenancy OCID here]

Now you will be asked to enter the default region. All the available regions are listed in the prompt. I am entering us-ashburn-1 as my default region.

Enter a region (e.g. ap-melbourne-1, ap-mumbai-1, ap-osaka-1, ap-seoul-1, ap-sydney-1, ap-tokyo-1, ca-toronto-1, eu-amsterdam-1, eu-frankfurt-1, eu-zurich-1, me-jeddah-1, sa-saopaulo-1, uk-gov-london-1, uk-london-1, us-ashburn-1, us-gov-ashburn-1, us-gov-chicago-1, us-gov-phoenix-1, us-langley-1, us-luke-1, us-phoenix-1): us-ashburn-1

Now you will be prompted to generate private and public key pair. Enter Y to proceed.

Do you want to generate a new RSA key pair? (If you decline you will be asked to supply the path to an existing key.) [Y/n]: Y

The key files will be generated to ~/.oci directory. You have a chance to change the directory where you generate them but I would leave it to the default location. Simply hit enter here.

Enter a directory for your keys to be created [/home/amaterasu48/.oci]:

You are not prompted to enter a name for the key. I would just leave it as default. Hit enter.

Enter a name for your key [oci_api_key]:

Next, you will be asked to enter a passphrase for the private key. This is optional, so it’s up to you whether you enter a passphrase or not. I’m leaving it blank in this example.

Enter a passphrase for your private key (empty for no passphrase):

Copy the public key to your clipboard.

$ cat ~/.oci/oci_api_key_public.pem

Back in Oracle Cloud Infrastructure UI, navigate to User Settings.

Click Add Public Key button.

Click PASTE PUBLIC KEYS, paste the copied public key from ~/.oci/oci_api_key_public.pem in the PUBLIC KEY text area and finally click Add button.

Back in your terminal, execute the following lines to check if your OCI CLI can actually talk to Oracle Cloud Infrastructure.

$ T=[your Tenancy OCID here]
$ oci compute image list --compartment-id $T

If it’s successful, you would get a list of available images for you to spin up instances (VM hosts) in JSON data.

It’s actually pretty fun to explore Oracle Cloud Infrastructure using CLI tool. You can find references here on Oracle’s official documentation site.

Leave a Reply

Your email address will not be published.