Setup Oracle OCI Command Line


The purpose of this page is to walk through the process of installing and configuring the Oracle OCI Command line interface. The Oracle OCI Command line interface is useful where certain commands are easier, scriptable, or unsupported in the Oracle Cloud UI.

This guide is not meant to be exhaustive but rather a quick start.


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

What’s covered in this guide

  1. Download and install the Oracle OCI CLI


Download and install OCI Command Line

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

Important Note


The Oracle OCI install process is governed by Oracle Corporation and may change at any moment. This page is meant as a guide. Please consult the Oracle OCI documentation for exact details of Oracle Cloud, Oracle OCI Command line and similar topics.

  1. Open a browser to the Oracle OCI quick start page here.
  2. Choose an appropriate environment and open a terminal window.
  3. Execute the download and install scripts for your enviroment:
    For example on Mac OSX:
    bash -c "$(curl -L"

    For example on Windows 10:
    Set-ExecutionPolicy RemoteSigned
    powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString(''))"

Configure OCI Environment

The Oracle 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, under windows:
    cd <OCI install root>\lib\oracle-cli\Scripts

    On success (oracle-cli) will be 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 Oracle OCI account.
    At the command line:
    oci setup keys
    On success a set of keys will be generated in the ~/.oci subdirectory.
    To verify examine the files in the directory using a command similar to: (Mac OSX Example shown)
    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 InstanceAn instance, or computer instance, is a virtual machine (VM) or individual physical computer, used to host a software appliance.
    1. Login 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. Click Add Public Key
    4. Paste the value of the oci public key PEM file and click Add.
  4. Create and populate the required OCI Config file.
    To populate the OCI config you will need 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 ODIC by either:
      If you're signed in as the user: Open the Profile menu (User menu icon) and click User Settings.

      If you're an administrator doing this for another user: Navigate to Identity and click Users.
      Select the user from the list.

    3. Copy the user OCID and return to the command line
    4. Paste the User ODIC at the User OCID prompt.
    5. Return to the OCI console and navigate to Administration > Tenancy Details.
    6. In the Tenancy Information tab click the copy button to copy the OCID.
    7. Return to the command line and paste the value atOICD prompt and hit return.
    8. Generate or enter the path to the private PEM file. For example ~/.oci/oci_api_key.pem
    9. Enter the passphrase used with the key.
    10. Enter y or no to the prompt asking about whether to store the passphrase. Okta recommends NOT storing the passphrase.

    The configuration process is now complete.