Install and configure OCI CLI
At step "Create instance" we have created the instance "deploymentmachine" which we would be using for installing and configuring OCI CLI.
Preparation for next steps
1. Login to instance "deploymentmachine" from a terminal; provide the Public IP you have in the Oracle Cloud UI:
root@isaacEXE:/home/zack/# ssh ubuntu@xx.xx.xx.xx
ubuntu@deploymentmachine:~$
ubuntu@deploymentmachine:~$ hostname
deploymentmachine
ubuntu@deploymentmachine:~$ id
uid=1001(ubuntu) gid=1001(ubuntu) groups=1001(ubuntu)
ubuntu@deploymentmachine:~$ pwd
/home/ubuntu
buntu@deploymentmachine:~$2. Become root user, and prepare the environment for installing OCI CLI
ubuntu@deploymentmachine:~$ sudo -i
root@deploymentmachine:~#
root@deploymentmachine:~#
root@deploymentmachine:~# apt-get update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB]
Hit:2 http://eu-frankfurt-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal InRelease
[ ... skip output ... ]3. Change the root password, and the ubuntu password:
Once again, SSH keys...
Now that we have updated our system, it is time to generate a pair of ssh keys on this particular machine. This time, we will be doing the whole process, step by step, since it will be pretty useful in the future:
1. Generate the SSH keys by running "ssh-keygen":
2. Modify /etc/ssh/sshd_config, and change the following:
3. Restart ssh service
4. Test if you can ssh into localhost
From now on, when connecting locally or from a remote instance via ssh, you will provide the password you have setup earlier.
Congrats! Your ssh service and keys are working properly!
1. Installing and configuring OCI CLI
Download and run install.sh script:
Keep pressing enter or provide required details, and choose Y or N when asked to...
2. Configure OCI CLI
[ 2.1 ] Collect the OCID of your Tenancy, Compartment and User.
I suggest you save the following details in a file located on the "deploymentmachine" instance .
[ 2.1.1 ] Tenancy OCID
Go to Oracle Cloud Menu, and from Administration choose Tenancy Details:

.. and copy the Tenancy OCID (as marked with green):

[ 2. 1. 2 ] Compartment OCID (in our case, the root compartment)
Go to Oracle Cloud Menu, and from Identity, choose Compartments

Select the root compartment (as marked with green):

... and copy the OCID

[ 2. 1. 3 ] User OCID
Go to Oracle Cloud Menu, and from Identity, and choose Users:

... and copy the OCID of user with Administrator rights (usually, the one you used to create the account)

In my case, I have saved all these details under a file (ready to be exported as environment variables):
[ 2.2 ] Generate RSA API Keys
[ 2.2.1 ] Create /root/.oci folder Create folder /root/.oci and file oci_api_private_key.pem under /root/.oci/ folder
[2.2.2] Generate API RSA private key Generate private RSA key and save it into oci_api_private_key.pem
[2.2.3] Generate fingerprint
Let's make it more presentable, and save it in a file, oci_api_key_fingerprint
[2.2.4] Generate API RSA public key
So far, we have the following files under /root/.oci
[2.2.5] Add API RSA public key to OCI User
a) Copy the content of your public key (oci_api_key_public.pem)
b) Under User you have been used for the getting the OCID (Oracle Cloud Menu > Identity > Users), scroll down to "Resources" section and click on "API Keys":

c) Paste the content of oci_api_key_public.pem when choosing "Paste Public Key", and click "Add":

[ 2.3 ] Generate OCI configuration file
Now we are /almost/ ready to run OCI CLI commands... first of all:
[2.3.1]Check version of oci cli tool (notice how oci tool has entire path)
[2.3.2] Create a valid CLI config file.
Remember that I have advised you to save the OCID of tenancy, user and compartment. You will need those details for this step
Run command "/root/bin/oci setup config" and provide the required details:
[2.3.3] Check if file properly configured:
3. Run a command just for testing
4. Call the tool without full path
We have keep running the command oci with the entire path /root/bin/oci. Let's add it's PATH to .bashrc:
References:
https://docs.cloud.oracle.com/Content/API/Concepts/apisigningkey.htm#How2
Last updated