How to Transfer Files Between an OCI VM (Compute Instance) and Object Storage (Part - 1)
I’m writing a small series of articles where I walk you through one of the most common tasks we perform on Oracle Cloud Infrastructure (OCI):
moving files between a VM and an Object Storage bucket.
Whether you want to upload backups from your VM or download files into a private subnet, the process becomes extremely simple once your OCI CLI is set up correctly.
In this article, I’ll cover three clear steps, just the way I explain it to anyone who asks me:
1) Install and configure OCI CLI - (This only)
Let’s begin!
1) Installing and Configuring OCI CLI
The very first prerequisite is simple:
👉 Your VM must have OCI CLI installed.
Log in to your VM using the opc user or any other privileged user.
I personally logged in using the oracle user (which was created during VM setup), and ran the installation from there.
Step 1: Install the OCI CLI
Run the following command:
curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh | bash
This script handles everything—from downloading the CLI to setting up environment variables.
[oracle@vm-test-1 ~]$ curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 17155 100 17155 0 0 186k 0 --:--:-- --:--:-- --:--:-- 188k
WARNING: Some interactive prompts may not function correctly if this script is piped into bash (e.g. 'curl "https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh" | bash)'
WARNING: Script should either be downloaded and invoked directly, or be run with the following command: bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
******************************************************************************
You have started the OCI CLI Installer in interactive mode. If you do not wish
to run this in interactive mode, please include the --accept-all-defaults option.
If you have the script locally and would like to know more about
input options for this script, then you can run:
./install.sh -h
If you would like to know more about input options for this script, refer to:
https://github.com/oracle/oci-cli/blob/master/scripts/install/README.rst
******************************************************************************
Downloading Oracle Cloud Infrastructure CLI install script from https://raw.githubusercontent.com/oracle/oci-cli/v3.68.1/scripts/install/install.py to /tmp/oci_cli_install_tmp_zdp8.
######################################################################## 100.0%
Running install script.
python3 /tmp/oci_cli_install_tmp_zdp8
-- Verifying Python version.
-- Python version 3.6.8 okay.
===> In what directory would you like to place the install? (leave blank to use '/home/oracle/lib/oracle-cli'):
-- Creating directory '/home/oracle/lib/oracle-cli'.
-- We will install at '/home/oracle/lib/oracle-cli'.
===> In what directory would you like to place the 'oci' executable? (leave blank to use '/home/oracle/bin'):
-- Creating directory '/home/oracle/bin'.
-- The executable will be in '/home/oracle/bin'.
===> In what directory would you like to place the OCI scripts? (leave blank to use '/home/oracle/bin/oci-cli-scripts'):
-- Creating directory '/home/oracle/bin/oci-cli-scripts'.
-- The scripts will be in '/home/oracle/bin/oci-cli-scripts'.
===> Currently supported optional packages are: ['db (will install cx_Oracle)']
What optional CLI packages would you like to be installed (comma separated names; press enter if you don't need any optional packages)?:
-- The optional packages installed will be ''.
-- Trying to use python3 venv.
-- Executing: ['/bin/python3', '-m', 'venv', '/home/oracle/lib/oracle-cli']
-- Executing: ['/home/oracle/lib/oracle-cli/bin/pip', 'install', '--upgrade', 'pip']
Collecting pip
Downloading https://files.pythonhosted.org/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl (1.7MB)
100% |████████████████████████████████| 1.7MB 1.1MB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Successfully installed pip-21.3.1
You are using pip version 21.3.1, however version 25.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
-- Executing: ['/home/oracle/lib/oracle-cli/bin/pip', 'install', '--cache-dir', '/tmp/tmpr32ini5k', 'wheel', '--upgrade']
Collecting wheel
Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.37.1
-- Executing: ['/home/oracle/lib/oracle-cli/bin/pip', 'install', '--cache-dir', '/tmp/tmpr32ini5k', 'oci_cli', '--upgrade']
Collecting oci_cli
Downloading oci_cli-3.71.0-py3-none-any.whl (25.2 MB)
|████████████████████████████████| 25.2 MB 40.6 MB/s
Collecting six>=1.15.0
Downloading six-1.17.0-py2.py3-none-any.whl (11 kB)
Collecting click==8.0.4
Downloading click-8.0.4-py3-none-any.whl (97 kB)
|████████████████████████████████| 97 kB 13.4 MB/s
Collecting jmespath==0.10.0
Downloading jmespath-0.10.0-py2.py3-none-any.whl (24 kB)
Collecting certifi>=2025.1.31
Downloading certifi-2025.4.26-py3-none-any.whl (159 kB)
|████████████████████████████████| 159 kB 97.5 MB/s
Collecting pyOpenSSL<=25.1.0,>=17.5.0
Downloading pyOpenSSL-23.2.0-py3-none-any.whl (59 kB)
|████████████████████████████████| 59 kB 13.1 MB/s
Collecting arrow>=1.0.0
Downloading arrow-1.2.3-py3-none-any.whl (66 kB)
|████████████████████████████████| 66 kB 10.9 MB/s
Collecting pytz>=2016.10
Downloading pytz-2025.2-py2.py3-none-any.whl (509 kB)
|████████████████████████████████| 509 kB 87.1 MB/s
Collecting terminaltables==3.1.10
Downloading terminaltables-3.1.10-py2.py3-none-any.whl (15 kB)
Collecting oci==2.164.0
Downloading oci-2.164.0-py3-none-any.whl (33.0 MB)
|████████████████████████████████| 33.0 MB 86.1 MB/s
Collecting prompt-toolkit==3.0.29
Downloading prompt_toolkit-3.0.29-py3-none-any.whl (381 kB)
|████████████████████████████████| 381 kB 36.3 MB/s
Collecting cryptography<46.0.0,>=3.2.1
Downloading cryptography-40.0.2-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.7 MB)
|████████████████████████████████| 3.7 MB 83.2 MB/s
Collecting PyYAML<=6.0.2,>=5.4
Downloading PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (677 kB)
|████████████████████████████████| 677 kB 90.0 MB/s
Collecting python-dateutil<3.0.0,>=2.5.3
Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
|████████████████████████████████| 229 kB 94.4 MB/s
Collecting importlib-metadata
Downloading importlib_metadata-4.8.3-py3-none-any.whl (17 kB)
Collecting circuitbreaker<2.0.0,>=1.3.1
Downloading circuitbreaker-1.4.0.tar.gz (9.7 kB)
Preparing metadata (setup.py) ... done
Collecting wcwidth
Downloading wcwidth-0.2.14-py2.py3-none-any.whl (37 kB)
Collecting typing-extensions
Downloading typing_extensions-4.1.1-py3-none-any.whl (26 kB)
Collecting cffi>=1.12
Downloading cffi-1.15.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (402 kB)
|████████████████████████████████| 402 kB 81.5 MB/s
Collecting pycparser
Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
|████████████████████████████████| 118 kB 82.6 MB/s
Collecting zipp>=0.5
Downloading zipp-3.6.0-py3-none-any.whl (5.3 kB)
Building wheels for collected packages: circuitbreaker
Building wheel for circuitbreaker (setup.py) ... done
Created wheel for circuitbreaker: filename=circuitbreaker-1.4.0-py3-none-any.whl size=7506 sha256=7e604a258e20a46edfdfd999605faec6d0a4ed5652229a140b4bec6b07f3c2eb
Stored in directory: /tmp/tmpr32ini5k/wheels/46/17/98/db2eb826e4a98da672cffe66ec16838182cde0cf19ad2c0c70
Successfully built circuitbreaker
Installing collected packages: pycparser, cffi, zipp, typing-extensions, six, cryptography, wcwidth, pytz, python-dateutil, pyOpenSSL, importlib-metadata, circuitbreaker, certifi, terminaltables, PyYAML, prompt-toolkit, oci, jmespath, click, arrow, oci-cli
Successfully installed PyYAML-6.0.1 arrow-1.2.3 certifi-2025.4.26 cffi-1.15.1 circuitbreaker-1.4.0 click-8.0.4 cryptography-40.0.2 importlib-metadata-4.8.3 jmespath-0.10.0 oci-2.164.0 oci-cli-3.71.0 prompt-toolkit-3.0.29 pyOpenSSL-23.2.0 pycparser-2.21 python-dateutil-2.9.0.post0 pytz-2025.2 six-1.17.0 terminaltables-3.1.10 typing-extensions-4.1.1 wcwidth-0.2.14 zipp-3.6.0
===> Modify profile to update your $PATH and enable shell/tab completion now? (Y/n):
===> Enter a path to an rc file to update (file will be created if it does not exist) (leave blank to use '/home/oracle/.bashrc'):
-- Backed up '/home/oracle/.bashrc' to '/home/oracle/.bashrc.backup'
-- Tab completion set up complete.
-- If tab completion is not activated, verify that '/home/oracle/.bashrc' is sourced by your shell.
-- ** Run `exec -l $SHELL` to restart your shell. **
-- Installation successful.
Announcement
============
1. Interactive mode now available in CLI
Have you tried the new interactive features in OCI CLI yet? You can get started by typing `oci -i`.
Learn more by watching our informative video on YouTube -> https://www.youtube.com/watch?v=lX29Xw1Te54&ab_channel=OracleLearning
Also see https://docs.oracle.com/iaas/Content/API/SDKDocs/cliusing_topic-Using_Interactive_Mode.htm
============
-- Run the CLI with /home/oracle/bin/oci --help
[oracle@vm-test-1 ~]$
[oracle@vm-test-1 ~]$
After installation, verify it:
oci --version
If you see the version printed, your CLI is installed successfully.
[oracle@vm-test-bl-ebs-1 ~]$ oci --version
/home/oracle/lib/oracle-cli/lib64/python3.6/site-packages/oci/_vendor/httpsig_cffi/sign.py:10: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6.
from cryptography.hazmat.backends import default_backend # noqa: F401
3.71.0
[oracle@vm-test-bl-ebs-1 ~]$
Step 2: Configure the OCI CLI
Next, we need to configure it with your OCI credentials.
Run: oci setup config
The CLI will ask for:
User OCID
Tenancy OCID
Region
Directory for storing API keys
Passphrase for the private key
[oracle@vm-test-1 ~]$ oci setup config
/home/oracle/lib/oracle-cli/lib64/python3.6/site-packages/oci/_vendor/httpsig_cffi/sign.py:10: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6.
from cryptography.hazmat.backends import default_backend # noqa: F401
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/oracle/.oci/config]:
Enter a user OCID: ocid1.user.oc1..aaaaaaaahtnchxxxxxxbbbbbbbccccccdddddddpumrcff4ja
Enter a tenancy OCID: ocid1.tenancy.oc1..aaaaaaaaq3kiaahtnchxxxxxxbbbbbbbccccccdddddddteja
Enter a region by index or name(e.g.
1: af-johannesburg-1, 2: ap-batam-1, 3: ap-chennai-1, 4: ap-chiyoda-1, 5: ap-chuncheon-1,
6: ap-chuncheon-2, 7: ap-dcc-canberra-1, 8: ap-dcc-gazipur-1, 9: ap-delhi-1, 10: ap-hyderabad-1,
11: ap-ibaraki-1, 12: ap-melbourne-1, 13: ap-mumbai-1, 14: ap-osaka-1, 15: ap-seoul-1,
16: ap-seoul-2, 17: ap-singapore-1, 18: ap-singapore-2, 19: ap-suwon-1, 20: ap-sydney-1,
21: ap-tokyo-1, 22: ca-montreal-1, 23: ca-toronto-1, 24: eu-amsterdam-1, 25: eu-budapest-1,
26: eu-crissier-1, 27: eu-dcc-dublin-1, 28: eu-dcc-dublin-2, 29: eu-dcc-milan-1, 30: eu-dcc-milan-2,
31: eu-dcc-rating-1, 32: eu-dcc-rating-2, 33: eu-dcc-zurich-1, 34: eu-frankfurt-1, 35: eu-frankfurt-2,
36: eu-jovanovac-1, 37: eu-madrid-1, 38: eu-madrid-2, 39: eu-madrid-3, 40: eu-marseille-1,
41: eu-milan-1, 42: eu-paris-1, 43: eu-stockholm-1, 44: eu-zurich-1, 45: il-jerusalem-1,
46: me-abudhabi-1, 47: me-abudhabi-2, 48: me-abudhabi-3, 49: me-abudhabi-4, 50: me-alain-1,
51: me-dcc-doha-1, 52: me-dcc-muscat-1, 53: me-dubai-1, 54: me-ibri-1, 55: me-jeddah-1,
56: me-riyadh-1, 57: mx-monterrey-1, 58: mx-queretaro-1, 59: sa-bogota-1, 60: sa-santiago-1,
61: sa-saopaulo-1, 62: sa-valparaiso-1, 63: sa-vinhedo-1, 64: uk-cardiff-1, 65: uk-gov-cardiff-1,
66: uk-gov-london-1, 67: uk-london-1, 68: us-ashburn-1, 69: us-ashburn-2, 70: us-chicago-1,
71: us-columbus-1, 72: us-gov-ashburn-1, 73: us-gov-chicago-1, 74: us-gov-phoenix-1, 75: us-langley-1,
76: us-luke-1, 77: us-newark-1, 78: us-phoenix-1, 79: us-saltlake-2, 80: us-sanjose-1,
81: us-somerset-1, 82: us-thames-1): 68
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/oracle/.oci]:
Enter a name for your key [oci_api_key]:
Public key written to: /home/oracle/.oci/oci_api_key_public.pem
Enter a passphrase for your private key ("N/A" for no passphrase):
Repeat for confirmation:
Private key written to: /home/oracle/.oci/oci_api_key.pem
Fingerprint: aa:3a:ff:d9:c5:10:7a:50:4f:ef:c0:f3:f4:b2:d2:72
Config written to /home/oracle/.oci/config
If you haven't already uploaded your API Signing public key through the
console, follow the instructions on the page linked below in the section
'How to upload the public key':
https://docs.cloud.oracle.com/Content/API/Concepts/apisigningkey.htm#How2
[oracle@vm-test-1 ~]$
[oracle@vm-test-1 ~]$
Note:- In above code snippets I kept most of the things default. But you can change it according to your environment.
Once you enter these inputs, the CLI will generate the required keys and a config file.
Next, we need to configure it with your OCI credentials.
Step 3: Add the API Key in OCI Console
This part is important.
Now that your CLI generated a public key, you must register it in OCI:
Log in to OCI Console, Open User Settings
Go to Tokens and Keys, Click on API Keys
Choose Add API Key
Upload the public key generated during the CLI setup
Once added, you will see a fingerprint — keep it noted; it confirms your key is active.
This completes the foundational setup.
Now your VM is ready to communicate with OCI Object Storage securely using the CLI.
In the next steps, I’ll show you how to upload from a public-subnet VM and download into a private-subnet VM using Bastion or direct CLI commands.
Thanks & Regards,
Chandan Tanwani



No comments:
Post a Comment