OCI stands for Oracle Cloud Infrastructure and the command line client (CLI) keep the same name: oci

The aim of this guide is to give a practical step by step quick flow, that I used on all new created vm, in order to have the oci cli working in no time.


The install directory is $HOME/oracle_cli with no optional packages. I added comments in the screenshot trace:

# Download and install the cli 
[email protected]:~$ bash -c "$(curl -L"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16926  100 16926    0     0  64101      0 --:--:-- --:--:-- --:--:-- 64357

    You have started the OCI CLI Installer in interactive mode. If you do not wish
    to run this in interactive mode, please include the --accept-all-defaults option.


# Give the lib install dir 
===> In what directory would you like to place the install? (leave blank to use '/home/ubuntu/lib/oracle-cli'): /home/ubuntu/oracle_cli/lib
-- Creating directory '/home/ubuntu/oracle_cli/lib'.
-- We will install at '/home/ubuntu/oracle_cli/lib'.

# Give the bin install dir
===> In what directory would you like to place the 'oci' executable? (leave blank to use '/home/ubuntu/bin'): /home/ubuntu/oracle_cli/bin
-- Creating directory '/home/ubuntu/oracle_cli/bin'.
-- The executable will be in '/home/ubuntu/oracle_cli/bin'.

===> In what directory would you like to place the OCI scripts? (leave blank to use '/home/ubuntu/bin/oci-cli-scripts'): /home/ubuntu/oracle_cli/oci-cli-scripts
-- Creating directory '/home/ubuntu/oracle_cli/oci-cli-scripts'.
-- The scripts will be in '/home/ubuntu/oracle_cli/oci-cli-scripts'.

# Give optional packages install dir (db is a current package to install)
===> Currently supported optional packages are: ['db (will install cx_Oracle)']
What optional CLI packages would you like to be installed (comma separated names; press enter if you don't need any optional packages)?:
-- The optional packages installed will be ''.

# Restart the shell 
[email protected]:~$ exec -l $SHELL

# Test that all is working 
[email protected]:~$ oci -version

Create the access keys

These keys can be created by using ssh-keygen or the fresh installe oci client. Let’s use the oci client.

# The command will create the $HOME/.oci directory
[email protected]:~$ oci setup keys

# The content of $HOME/.oci directory
[email protected]:~$ ls .oci
oci_api_key.pem  oci_api_key_public.pem

Create the API Key from the user page

Grab generated public key

[email protected]:~$ cat .oci/oci_api_key_public.pem
-----END PUBLIC KEY-----

and copy it into the “Add API Key” window from “Identity > Users > User Details” page of your user.

Final step, copy the generated config file from the “Configuration File Preview” window into the $HOME/.oci/config file.

[email protected]:~$ cat .oci/config

At this moment the environnement is configured and oci commands can be executed (example bellow on dns parameters):


Share on