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 to upload and download files between on-prem servers and Oracle Cloud Infrastructure (Object Storage).
Useful tool, for example, for small-medium Oracle database migrations where the migration can be carried out through an export/import. Start.
Installing OCI CLI
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 do not have it previously, Python version 3. You can still see which 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 OCI CLI installation on the server is complete, we check the installed version with the following command:
[root@test /root]$ oci --version 3.4.4
Configuration
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 script: User API Signing Key, OCID and Tenancy OCID: https://docs.cloud.oracle.com/Content/API/Concepts/apisigningkey.htm#Other Region: https://docs.cloud.oracle.com/Content/General/Concepts/regions.htm General config documentation: https://docs.cloud.oracle.com/Content/API/Concepts/sdkconfig.htm 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(e.g. 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': https://docs.cloud.oracle.com/Content/API/Concepts/apisigningkey.htm#How2
Once configured, we go to the path where the configuration file has been created:
[root@test /root/.oci]$ pwd /root/.oci [root@test /root/.oci]$ ls -lart total 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 contents of the file must be copied oci_api_key_public.pem in the API Keys resource of the user that we MUST 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 contents of the file mentioned above.

With this, we would already have installed and configured the OCI CLI and, we would be able to use the OCI CLI tool to upload / download files between OCI and our on-prem server.
I hope you find it useful. If you don’t want to miss any posts. Sign up for our newsletter. With one email per month, you will be informed.
Still don’t know Query Performance? Find out how it can help you in your Oracle environment. Learn more on their LinkedIn page.
Follow GPS on LinkedIn