Reading Time: 3 minutes
In this tutorial “How to install oci cli in Linux” We will show you how to install and configure OCI cli client.
Table of Contents
What is OCI
OCI stands for Oracle cloud infrasturcture. Oracle Cloud is a cloud computing service offered by Oracle Corporation providing servers, storage, network, applications and services through a global network of Oracle Corporation-managed data centers. The company allows these services to be provisioned on-demand over the Internet.
Validate OCI
You can check if OCI is already installed using the below options. You can either check this using which command or oci –version, If it is not installed on your profile then you need to install it.
$ which oci
$ oci --version
How to install oci cli in Linux
Open Terminal and ssh
You must have ssh access to Linux Hosts. If you do not have root or sudo access it is fine. You can follow the steps on How to ssh to Linux Hosts. if you are using a Windows computer.
We recommend you use non-root account to configure OCI, In case you do not have non-root account, You can create one by using the steps mentioned here(How to create Linux Account)
To run the installer script, run the following command
$ bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
In what directory would you like to place the install? – You can press “Enter” or change the path however recommend you to use the default path which is under the home directory.
In what directory would you like to place the ‘oci’ executable? – You can press “Enter” or change the path however recommend you to use the default path which is under the home directory.
In what directory would you like to place the OCI scripts? – You can press “Enter” or change the path however recommend you to use the default path which is under the home directory.
Modify profile to update your $PATH and enable shell/tab completion now? – Press “Y”
Enter a path to an rc file to update (file will be created if it does not exist) – You can press “Enter” or change the path however recommend you to use the default path which is under the home directory.
Validate OCI
You can check if OCI is already installed using the below options. You can either check this using which command or oci –version, If it is not installed on your profile then you need to install it however as you already installed it now you should see OCI is installed in your profile.
$ which oci
$ oci --version
Now you have successfully installed OCI however in order to use oci cli you need to configure it as well
Setting up the OCI CLI Configuration File
To have the CLI guide you through the first-time setup process, use the setup config
command:
$ oci setup config
Confirm Your User and Fingerprint Information
You can confirm your user and fingerprint information by logging onto the OCI console, opening the profile menu in the upper right, and then selecting your user name.
Once you select your user name, you will see your OCID in the User Information panel. This OCID should be the user entry in your configuration file.
You can find your fingerprint by navigating to the API Keys section under the Resources column on the lower left.
Adding Comments to the Configuration File
Be sure not to add in-line comments to your configuration file. Add all comments on a new line. For example:
[DEFAULT]
user=ocid1.user.oc1..<unique_ID>
fingerprint=<your_fingerprint>
key_file=~/.oci/oci_api_key.pem
tenancy=ocid1.tenancy.oc1..<unique_ID>
# Some comment
region=us-ashburn-1
You can create your ssh public key and keep it in your home directory and replace the path in the above example. In this above example key_file=~/.oci/oci_api_key.pem(Replace .pem file location with your .pem file location). If you have not created ssh key then you need to create it using ssh-keygen
the command and the same public key needs to be uploaded on OCI console under API Keys (See above steps)
Conclusion:
We hope this tutorial “How to install oci cli in Linux” helped you to configure OCI CLI.