OCI CLI: Installation and configuration on Linux

Hello everyone. Today we are going to talk about the installation and configuration of OCI CLI on Linux. This OCI tool will be useful to have installed if you are going to work with Oracle Cloud Infrastructure in the future.

It is a very useful tool for uploading and downloading files between on-prem servers and Oracle Cloud Infrastructure (Object Storage).

Useful tool, for example, for small-medium sized Oracle database migrations where the migration can be done through an export/import. Let’s get started.

OCI CLI Installation

Before starting, we check the version of Linux that we have on our server:

[root@test /root]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)

We open a terminal with root user and execute the following:

Note: This OCI CLI installation installs, if you don’t already have it, Python version 3. You can, however, see what version is installed with the following command:

[root@test /root]$ python3 --version
Python 3.6.8

Next, we launch the installation:

[root@test /root]$ bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"

Once the installation of OCI CLI on the server is finished, we check the installed version with the following command:

[root@test /root]$ oci --version


To launch the configuration, the command is as follows:

[root@test /home/oracle]$ oci setup config
 This command provides a walkthrough of creating a valid CLI config file.
 The following links explain where to find the information required by this
 User API Signing Key, OCID and Tenancy OCID:
 General config documentation:

Enter a location for your config[/root .oci/config] :
Enter a user OCID: ocid1.user.oc1..aaaaaaaaujtkvgbd7ern4p6w2pdwk3o6yz4nnd4mu2kdpetydo67v3xak24q
Enter a tenancy OCID: ocid1.tenancy.oc1..aaaaaaaaao6lid7pht4vw7opfij7ydnvrcyqs2nawvfigmllx3z2nve6h4pq
Enter a region by index or name(eg
1: af-johannesburg-1, 2: ap-chiyoda-1, 3: ap-chuncheon-1, 4: ap-hyderabad-1, 5: ap-ibaraki-1,
6: ap-melbourne-1, 7: ap-mumbai-1, 8: ap-osaka-1, 9: ap-seoul-1, 10: ap-singapore-1,
11: ap-sydney-1, 12: ap-tokyo-1, 13: ca-montreal-1, 14: ca-toronto-1, 15: eu-amsterdam-1,
16: eu-frankfurt-1, 17: eu-marseille-1, 18: eu-milan-1, 19: eu-stockholm-1, 20: eu-zurich-1,
21: il-jerusalem-1, 22: me-abudhabi-1, 23: me-dcc-muscat-1, 24: me-dubai-1, 25: me-jeddah-1,
26: sa-santiago-1, 27: sa-saopaulo-1, 28: sa-vinhedo-1, 29: uk-cardiff-1, 30: uk-gov-cardiff-1,
31: uk-gov-london-1, 32: uk-london-1, 33: us-ashburn-1, 34: us-gov-ashburn-1, 35: us-gov-chicago-1,
36: us-gov-phoenix-1, 37: us-langley-1, 38: us-luke-1, 39: us-phoenix-1, 40: us-sanjose-1): 32
Do you want to generate a new API Signing RSA key pair? (If you decline you will be asked to supply the path to an existing key.)[Y/n] : AND
Enter a directory for your keys to be created[/root .oci] :
Enter a name for your key[oci_api_key] :
Public key written to: /root/.oci/oci_api_key_public.pem
Enter a passphrase for your private key (empty for no passphrase):
Private key written to: /root/.oci/oci_api_key.pem
Fingerprint: 93:69:08:d7:23:c7:64:28:76:4f:9a:82:f9:97:5a:7e
Config written to /root/.oci/config

 If you haven't already uploaded your API Signing public key through the
 console, follow the instructions on the page linked below in the section
 'How to upload the public key':

Once configured, we go to the path where the configuration file has been created:

[root@test /root/.oci]$pwd
[root@test /root/.oci]$ ls -lart
full 20
dr-xr-x---. 9 root root 4096 Jan 27 13:15 ..
-rw-------. 1 root root 451 Jan 27 13:42 oci_api_key_public.pem
-rw-------. 1 root root 1704 Jan 27 13:42 oci_api_key.pem
-rw-------. 1 root root 295 Jan 27 13:42 config
drwx------. 2 root root 4096 Jan 27 13:42 .

At this point, we want to comment that the content of the oci_api_key_public.pem file must be copied to the user’s API Keys resource that we SHOULD have created at the OCI level so that the server-OCI connection is established.

In the screenshot you can see that in the OCI user oscar.gavilan a new API Key has been created with the content of the file mentioned above.

OCI CLI Installation and Configuration

With this, we would already have the OCI CLI installed and configured, and we would be able to use the OCI CLI tool to upload/download files between OCI and our on-prem server.

I hope it will be useful to you. If you don’t want to miss any publication. Sign up for our newsletter . With an email a month, you will be informed.

Still do not know Query Performance ? Find out how it can help you in your Oracle environment. More information on their page LinkedIn .

Follow GPS on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *