Install Oracle Cloud Infrastructure Command Line Interface

The following demonstrates how to install and configure Oracle Cloud Infrastructure Command Line Interface (OCI-CLI). The OCI-CLI enables you to perform tasks easier than using the UI, use scripting, and offers functionality that's unsupported in the Oracle Cloud UI.

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 macOS.

Download and install OCI command line

The OCI-CLI is available for Windows, Linux, and macOS.

The OCI installation process is governed by Oracle Corporation and is subject to change. This page is meant as a guide. Consult Oracle documentation for current details.

  1. Go to the Oracle OCI Quick Start page.
  2. Open a terminal window in your environment. Execute the download and install scripts for your environment: For example, on macOS:
    Copy

    Download OCI command line - macOS

    bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)
    For example, on Windows 10:
    Copy

    Download OCI command line - Windows

    Set-ExecutionPolicy RemoteSignedpowershell -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 of the Oracle OCI scripts. Activate the OCI command line interface.

    For example, in Windows:

    cd <OCI install root>\lib\oracle-cli\Scriptsactivate

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

    In macOS:

    cd ~/lib/oracle-cli/binsource activate
  2. Run the oci setup keys command to create a set of required keys and upload them to your OCI account: oci setup keysOn success, a set of keys is generated in the ~/.oci subdirectory. You can verify that they were created by listing the files in the directory. It should contain the files oci_api_key.pem and oci_api_key_public.pem.
  3. Upload the keys to the Oracle Cloud Instance:
    1. Sign in to the Oracle OCI Cloud Console.
    2. To upload the keys as the user you're currently signed-in as, click your username in the top-right corner of the console, then click User Settings.If you're an administrator doing this for another user, 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.
    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