Welcome to OCI. If you are wondering how to install OCI CLI and configure it on your offline
computer, you have come to the right place. We are going to show you exactly how to do that.
Offline installation here refers to the installation of OCI CLI,
on your workstation or computer where there is no public internet access. OCI CLI connects to OCI
services through the service gateway. Please refer to the links in this
video description for videos on Online installation of OCI CLI.
In this video we will install OCI CLI on computer with Windows- based operating system.
Here are the prerequisites for offline installation of OCI CLI.
Let’s first visit the official OCI documentation and see what is in there.
If you have a Python version between 3.6 and 3.9 installed on your computer,
you can perform an offline installation of OCI CLI.
To perform an offline installation, let’s go to OCI CLI release page on GitHub and select the
version of CLI that we are interested to install. Scroll down to the Assets section of the release
page and click on the zip file to download it. Now, let’s copy the zip file to the target system.
I have an OCI compute instance running on Windows OS.
Let’s connect to it and open the PowerShell console using the run as administrator option.
We are running this command in Microsoft Windows Server 2022 Standard Edition.
The next step in the documentation is to place the installer zip file in the target system.
I have copied the installer zip file here in my Windows system.
Also, as a prerequisite, I have installed Python 3.9 version.
Now, the next step is to unzip the installer zip file.
As we see, we have a directory created OCI CLI installation as we have extracted the zip file.
And under that, there are two scripts. One with PowerShell
extension and the other one is Python script. And the directory oci-cli-installation.
The installer enables auto complete by installing and running a script.
To allow the script to run, we must enable the remote signed execution
policy or unrestricted execution policy. To configure the remote or unrestricted
execution policy for Power Shell, let’s run the command Set ExecutionPolicy Unrestricted.
Or Set ExecutionPolicy RemoteSigned. For this demo we are going with ‘Unrestricted’.
Let’s change the directory t the location where the Power Shell installer is in place.
Let’s go to the documentation and look at the next step.
The next step is to run the install.ps1 -OfflineInstall
so that it starts the installation. As we are in the path of install.ps1
script, we have to run dot slash install.ps1 – OfflineInstall.
As we hit enter, there is a security warning to confirm whether to run the
script or not, as it is not a trusted one. Let’s proceed and run the script for once.
As we run it the script is running the OCI CLI offline installation, and it is trying to fetch
the Python version. And the installed Python version is 3.9.9.
Now it is prompting us, asking what directory would we like to place the
install. Let’s go with the default option. It’s now prompting us where to put in the OCI
executable. Let’s go with the default option. The next step is to follow
the installation prompts. Let’s go ahead and follow the prompts.
Now, it is asking us where to place the OCI scripts.
Let’s go with the default option. Now, as we see the script is trying to
install the OCI CLI dependency packages. Let the Python magic go on.
Once the dependencies are installed, the script is prompting us to confirm whether the path
variable should be modified to include the CLI and enable the tab completion in Powe Shell now.
Let’s proceed with “Yes”. There we are! Our installation is successful.
As the script suggest’s, let us run oci.exe - -help to print the help page of OCI CLI.
To verify OCI CLI installation, let’s run oci -v command, which would result the OCI CLI installed
version as the output. Let’s try to fetch
the OCI object storage namespace. We will run oci os ns get command to do this.
As we see we have ended up with an error saying that OCI CLI could not
find the configuration file at the default location under the home directory.oci\config.
And it is prompting us whether we want to create a new configuration file now.
Let’s proceed with ‘No’. If you are using the CLI,
we must create a configuration file that contains the required credentials for working
with Oracle Cloud Infrastructure. We can create this file using a
setup dialog or manually using a text editor. To have the CLI guide you through the first-time
setup process, use the OCI setup config command. This command prompts us for the
information required to create the configuration file. For this demo,
I am using an already uploaded API signing Key. As we run the OCI setup config,it is prompting
us to confirm the location for the configuration to be in place. Let’s go with the default.
It’s prompting us to enter the User OCID. Let’s paste the user OCID.
And now it is asking us to give the Tenancy OCID. Let’s give that as well.
Now, it is asking us to enter a region by its index or name.
For this demo, we will go with Amsterdam whose index is 16. Let’s go with it.
Now, the script is asking us whether we want to generate an API signing
RSA key pair. We will proceed with ‘No’. Let’s enter the location of API private
key. After we enter the location, of API signing private key file, let’s hit enter.
The fingerprint is automatically captured from the private key file and the configuration is
written to .oci\config under home directory. If we have not already uploaded our API signing
public key to the console, we have to do that now. I have already uploaded the public key
in the OCI Console for this user. Let’s run the oci os ns get command
to fetch the object storage namespace now. As we see, the object storage namespace
is displayed now. To verify whether OCI
CLI is configured or not, we can run oci iam region list command to list the OCI regions.
As we see the output is shown with OCI region key and OCI region name.
Thank you for watching. Hope this video was helpful.