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.

Steps

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.

Important Note

Important

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.
  3. Execute the download and install scripts for your enviroment:
    For example, on Mac OSX:
    bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"

    For example, on Windows 10:
    Set-ExecutionPolicy RemoteSigned
    powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.ps1'))"

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
    activate

    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. 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 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 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 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 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. We recommend that you don't store the passphrase.

    The configuration process is now complete.