Install Oracle Cloud Infrastructure Command Line Interface (OCI-CLI)

The Oracle Cloud Infrastructure Command Line Interface (OCI-CLI) is useful where certain commands are easier, scriptable, or unsupported in the Oracle Cloud UI. This page guides you through process of installing and configuring the OCI-CLI.

This guide isn't meant to be exhaustive but rather a quick start.


Before you begin

Ensure that you have:

  • An Oracle OCI account (not classic).
  • Access to a supported OCI command line environment, such as Windows, Linux or Apple OSX.

Download and install OCI command line

The OCI command line tool kit can be installed in Windows, Linux and Mac OSX Environments.

The OCI install process is governed by Oracle Corporation and may change over a period of time. This page is meant as a guide. Consult the Oracle documentation for details of Oracle Cloud, OCI Command line, and similar topics.

  1. Go to the Oracle OCI Quick Start page.
  2. Choose an appropriate environment and open a terminal window.Execute the download and install scripts for your enviroment:For example, on Mac OSX:

    Download OCI command line - OSX

    bash -c "$(curl -L
    For example, on Windows 10:

    Download OCI command lineline - Windows

    Set-ExecutionPolicy RemoteSignedpowershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(''))"

Configure an OCI-CLI environment

The OCI-CLI environment must be activated and configured for use. This includes creating an appropriate OCI configuration file and populating that file with information about the target OCI account.

  1. Open a terminal window and change directory to the location where the Oracle OCI scripts where installed and activate the OCI command line interface.
    For example, in Windows:
    cd <OCI install root>\lib\oracle-cli\Scripts

    On success, (oracle-cli) is added to the command prompt.

    On Mac OSX:
    cd ~/lib/oracle-cli/bin
    source activate

  2. Execute the oci setup keys command to create a set of required keys and upload to your OCI account.
    At the command line:
    oci setup keys
    On success, a set of keys is generated in the ~/.oci subdirectory.
    To verify, examine files in the directory using a command similar to:
    (Example for Mac OSX)
    ls -lha ~/.oci/
    total 16
    . . .
    -rw------- 1 ociuser staff 1.7K Dec 12 09:56 oci_api_key.pem
    -rw------- 1 ociuser staff 451B Dec 12 09:56 oci_api_key_public.pem

  3. Upload the keys to the Oracle Cloud Instance.
    1. Sign in to the Oracle OCI Cloud Console
    2. If you're signed in as this user, click your username in the top-right corner of the Console, and then click User Settings.
      If you're an administrator doing this for another user, instead click Identity, click Users, and then select the user from the list.

    3. Select Resources > API Keys.
    4. In the API Keys pane, click Add APIKey.
    5. Select Paste Public Key.
    6. Paste the value of the OCI public key PEM file and click Add.
  4. Create and populate the required OCI Configuration file.
    To populate the OCI configuration, you must have your region code, your tenancy OCID, and your user OCID.
    1. At the command line, execute:
      oci setup config
    2. Return to the OCI console and determine the user OCID in one of the following ways:
      If you're the user, open the Profile menu (User menu icon) and click User Settings.

      If you're an administrator doing this on behalf of another user, navigate to Identity and click Users.
      The select the user from the list.

    3. Copy the user OCID and return to the command line.
    4. Paste the user OCID at the User OCID prompt
    5. Return to the OCI console and navigate to Administration > Tenancy Details.
    6. In the Tenancy Information tab, click Copy to copy the OCID.
    7. Return to the command line and paste the value at the OICD prompt and hit return.
    8. Return to the OCI console and examine the Region.
    9. Return to the command line and enter the associated region.
      See Regions and availability domains for a complete list of all Regions and their associated identifiers.
    10. Generate or enter the path to the private PEM file. For example, ~/.oci/oci_api_key.pem
    11. If required, enter the passphrase used with the key.
    12. Enter y or no to the prompt asking about whether to store the passphrase. Okta recommends that you don't store the passphrase.

    The configuration process is now complete.

Next steps

Create compartment