Skip to main content

Setting up an Oracle Cloud OCI Command Line (CLI) in Oracle Linux 8

Setting up an OCI Command Line (CLI) in Oracle Linux 8



Oracle Cloud Infrastructure Command Line Interface (OCI CLI) is a powerful tool that allows you to manage your Oracle Cloud Infrastructure resources and services through the command line. It provides a way to automate and script tasks, create and manage resources, and interact with your cloud environment programmatically. Here's a step-by-step guide to installing and setting up OCI CLI.

Before you start, ensure you have the following prerequisites:


Oracle Cloud Account: You need an active Oracle Cloud account.



Steps:

1) I will create a server with Oracle Linux 8 on OCI always free to use as a centralized OCI CLI server.

It will be completed within 5 mins in OCI.




2)  It would a good choice to update server before installing the CLI. It will be a time taking process.

[opc@ocicliserver ~]$ sudo dnf update


3) Now Lets Install OCI CLI.

[opc@ocicliserver ~]$ sudo dnf -y install oraclelinux-developer-release-el8

[opc@ocicliserver ~]$ sudo dnf install python36-oci-cli

Make sure the installation is successful.

To uninstall the CLI:

sudo dnf remove python36-oci-cli

4)  Check the OCI CLI version 

[opc@ocicliserver ~]$ oci --version

3.23.2


5) Now we will setup the OCI to work with our Cloud Account.

CLI will provide a guided interface to setup using oci setup config

Please use below method to find the required information that is needed for setup.

To find USER OCID : Go to cloud account and login to OCI Console Profile> User Settings and copy the OCID ID for the user.





To find the Tenancy OCID: Go to cloud account and login to OCI Console Profile>Tenancy and copy the tenancy OCID.




To find the region Name:  Go to the top ribbon and check the region name. Click on manage region to find the region identifier. Like in my case ap-hyderabad-1.




After we have all required information, I will do the setup using below command.

[opc@ocicliserver ~]$ 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 [/home/opc/.oci/config]: -->Hit enter to use default location.
Enter a user OCID: ocid1.user.oc1..aaaaaaaarnhjftgeirzqh46eukw3eogdx5qeko2fkpydzgnco7saxyud7ykq
Enter a tenancy OCID: ocid1.tenancy.oc1..aaaaaaaa6t2hb4hut3nde4luzi6xelomsgkksar42w7o6tydf5fdkkkz2ieq
Enter a region by index or name(e.g.
1: af-johannesburg-1, 2: ap-chiyoda-1, 3: ap-chuncheon-1, 4: ap-dcc-canberra-1, 5: ap-hyderabad-1,
6: ap-ibaraki-1, 7: ap-melbourne-1, 8: ap-mumbai-1, 9: ap-osaka-1, 10: ap-seoul-1,
11: ap-singapore-1, 12: ap-sydney-1, 13: ap-tokyo-1, 14: ca-montreal-1, 15: ca-toronto-1,
16: eu-amsterdam-1, 17: eu-dcc-dublin-1, 18: eu-dcc-dublin-2, 19: eu-dcc-milan-1, 20: eu-dcc-milan-2,
21: eu-dcc-rating-1, 22: eu-dcc-rating-2, 23: eu-frankfurt-1, 24: eu-madrid-1, 25: eu-marseille-1,
26: eu-milan-1, 27: eu-paris-1, 28: eu-stockholm-1, 29: eu-zurich-1, 30: il-jerusalem-1,
31: me-abudhabi-1, 32: me-dcc-muscat-1, 33: me-dubai-1, 34: me-jeddah-1, 35: mx-queretaro-1,
36: sa-santiago-1, 37: sa-saopaulo-1, 38: sa-vinhedo-1, 39: uk-cardiff-1, 40: uk-gov-cardiff-1,
41: uk-gov-london-1, 42: uk-london-1, 43: us-ashburn-1, 44: us-chicago-1, 45: us-gov-ashburn-1,
46: us-gov-chicago-1, 47: us-gov-phoenix-1, 48: us-langley-1, 49: us-luke-1, 50: us-phoenix-1,
51: us-sanjose-1): ap-hyderabad-1
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]: Y
Enter a directory for your keys to be created [/home/opc/.oci]: --> Hit Enter to use default location
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): 
Repeat for confirmation: 
Private key written to: /home/opc/.oci/oci_api_key.pem
Fingerprint: 35:3a:56:4e:32:82:88:d2:44:04:ca:d0:d1:58:b0:26
Do you want to write your passphrase to the config file? (If not, you will need to enter it when prompted each time you run an oci command) [y/N]: y
Config written to /home/opc/.oci/config



6) Now the setup is completed on server. We will need to upload the API key on OCI user which will be using for authentication.

Let's see the file which were created in earlier step.

[opc@ocicliserver .oci]$ pwd
/home/opc/.oci
[opc@ocicliserver .oci]$ ls -ltr
total 12
-rw-------. 1 opc opc  451 Aug 15 06:46 oci_api_key_public.pem
-rw-------. 1 opc opc 1874 Aug 15 06:47 oci_api_key.pem
-rw-------. 1 opc opc  324 Aug 15 06:47 config


copy the content from the public key(oci_api_key_public.pem) and go to Cloud console, Profile> User Settings> Go on Resource> API keys and add the key.








Once added, we will see the fingerprint in the API keys list.



Thats complete our OCI CLI setup.

7) Let test if we are able to run a command from CLI now.

[opc@ocicliserver ~]$ oci iam compartment list |grep -i name
      "name": "foabox_compartment",
      "name": "funoracleapps_site",
      "name": "gold1_compartment",
      "name": "ManagedCompartmentForPaaS",
      "name": "sandbox_compartment",

Hurray we are able to get the information from Command line now.

We can use various commands to manage resources, create instances, configure networking, and perform other tasks in our Oracle Cloud Infrastructure environment.





If you like please follow and comment

Comments

Popular posts from this blog

WebLogic migration to OCI using WDT tool

WebLogic migration to OCI using WDT tool Oracle WebLogic Deploy Tool (WDT) is an open-source project designed to simplify and streamline the management of Oracle WebLogic Server domains. With WDT, you can export configuration and application files from one WebLogic Server domain and import them into another, making it a highly effective tool for tasks like migrating on-premises WebLogic configurations to Oracle Cloud. This blog outlines a detailed step-by-step process for using WDT to migrate WebLogic resources and configurations. Supported WLS versions Why Use WDT for Migration? When moving Oracle WebLogic resources from an on-premises environment to Oracle Cloud (or another WebLogic Server), WDT provides an efficient and reliable approach to: Discover and export domain configurations and application binaries. Create reusable models and archives for deployment in a target domain. Key Pre-Requisites Source System: An Oracle WebLogic Server with pre-configured resources such as: Applica...

How to Validate TDE Wallet Password in Oracle Database

How to Validate TDE Wallet Password in Oracle Database Validating the Transparent Data Encryption (TDE) wallet password is crucial, especially when ensuring that the password is correct without using the OPEN or CLOSE commands in the database. This blog post explains a straightforward method to validate the TDE password using the mkstore utility. Steps to Validate TDE Wallet Password Follow these steps to validate the TDE wallet password: Step 1: Copy the Keystore/Wallet File Navigate to your existing TDE wallet directory. Copy only the ewallet.p12 file to a new directory. If a cwallet.sso file exists, do not copy it . The absence of cwallet.sso ensures that the wallet does not use auto-login, forcing the utility to prompt for the password. Step 2: Validate Using mkstore Use the mkstore utility to check the contents of the wallet file. The mkstore utility will prompt you for the TDE wallet password, allowing you to validate its correctness. Command Syntax To display the conten...

How to Create macOS Catalina ISO File

  How to Create macOS Catalina ISO File Please note these steps need to be performed on a Apple Mac System to generate an iso. Steps: 1) Download macOS Catalina From App Store or Apple download 2) Please note once you download it will be in dmg format. 3) Open Terminal in MAC.  from the top-right corner open up Spotlight.  Type in Terminal and hit Enter. 4)  Mount it to your macOS hdiutil attach /tmp/Catalina.dmg -noverify -mountpoint /Volumes/Catalina 5) Create macOS Catalina Installer sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia --volume /Volumes/Catalina --nointeraction 6) Unmount Catalina Disk hdiutil detach /volumes/Install\ macOS\ Catalina 7) Convert the DMG file to an ISO file hdiutil convert /tmp/Catalina.dmg -format UDTO -o ~/Desktop/Catalina.cdr 8) Rename and Move to Desktop mv ~/Desktop/Catalina.cdr ~/Desktop/Catalina.iso Now we can use this iso on any system and install on virtual machines.