Saturday, January 11, 2020

Installing OCI-CLI in Oracle Cloud

In this blog post, i will describe installation and configuration of command line interface in Oracle Cloud. Before we start, we should have the below details ready.

1. OCI Users
2. SSH Keypair used for signing API requests, with the public key being uploaded to the Oracle OCI.
3. Python

We should have python version 3 and above else we may get the following message:-

WARNING: Python 2 support is ending on December 31, 2019. Future versions of OCI CLI after January 2020, will not be compatible with Python 2. To avoid interruption at that time, please install OCI CLI in a compatible Python 3 environment.


Installing Python:-

Using root user

yum install gcc libffi-devel python-devel openssl-devel

yum install python36

ln -s /usr/bin/python36 /usr/bin/python3


[root@cloud opc]# python3 --version
Python 3.6.8



Installing CLI:-

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



Configuring CLI:-


We should have the below details ready:-


Tenancy OCID
Compartment OCID
User OCID
SSH Keys





[opc@cloud ~]$ oci setup config

Enter a location for your config [/home/opc/.oci/config]:
Enter a user OCID: ocid1.user.oc1..aaaaaaaaxvnXXXXXXXXXXXXXXXXXXXXXXX
Enter a tenancy OCID: ocid1.tenancy.oc1..XXXXXXXXXXXXXXXXXXXXXX
Enter a region (e.g. ap-mumbai-1, ap-seoul-1, ap-sydney-1, ap-tokyo-1, ca-toronto-1, eu-frankfurt-1, eu-zurich-1, sa-saopaulo-1, uk-london-1, us-ashburn-1, us-gov-ashburn-1, us-gov-chicago-1, us-gov-phoenix-1, us-langley-1, us-luke-1, us-phoenix-1): XXXXXX
Do you want to generate a new RSA key pair? (If you decline you will be asked to supply the path to an existing key.) [Y/n]: y
Enter a directory for your keys to be created [/home/opc/.oci]:
Enter a name for your key [oci_api_key]:
Public key written to: /home/opc/.oci/oci_api_key_public.pem
Enter a passphrase for your private key (empty for no passphrase):
Private key written to: /home/opc/.oci/oci_api_key.pem
Fingerprint: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Config written to /home/opc/.oci/config


copy the public key to the public key content to the API keys section of the OCI user


Once we upload the key, it will generate a fingerprint which should match the fingerprint generated during CLI setup section.



Now verify if CLI setup has been done properly or not.

[opc@cloud .oci]$ oci iam availability-domain list







[opc@cloud ~]$ oci network vcn list --compartment-id "Compartment OCID"




Now, we can use CLI to automate our administrative tasks. Hope, it helps someone

Happy learning cloud....................









2 comments:

  1. I like this post because it contains a lot of useful information to read, maybe everyone will like me. I hope this post of yours will be more appreciated by it really excellent, i enjoyed it, thanks for posting it on oracle.
    DevOps Training in Chennai

    DevOps Online Training in Chennai

    DevOps Training in Bangalore

    DevOps Training in Hyderabad

    DevOps Training in Coimbatore

    DevOps Training

    DevOps Online Training

    ReplyDelete