OCI user OCID: where to find the user OCID, tenancy OCID, compartment and fingerprint, and why the CLI returns 401

Tenancy OCID: Profile → Tenancy. User OCID: Profile → User settings. Where the fingerprint shows, a ~/.oci/config that works and the 8 causes of a 401.

2026-11-12

This site's OCI guide explains how to generate the API key and paste it into Control Cloud. Search Console shows people arriving with searches like "user ocid" and "oci auth", which is the step before: where each value lives and why the CLI answers 401. This note gathers the Console paths for the user OCID, the tenancy OCID and a compartment OCID, the region and the fingerprint, what ~/.oci/config looks like, how to test it with the CLI, and the NotAuthenticated causes Oracle documents. Everything comes from docs.oracle.com; the source list is at the end.

Where each value lives in the Console

The short path: Add API Key and the Console snippet

In User settings, the user's API keys section (depending on the Console version it shows as API Keys or as Token and keys) → Add API Key → Download Private Key → Add. Once added, the Console shows a Configuration File Preview with the five fields the file needs. Copy it as is into ~/.oci/config and only fix key_file with the path where you saved the private key. If you lost it, you can get it back: in the fingerprint list, the Actions menu (three dots) → View configuration file.

[DEFAULT]
user=ocid1.user.oc1..<unique_ID>
fingerprint=12:34:56:78:90:ab:cd:ef:12:34:56:78:90:ab:cd:ef
key_file=~/.oci/oci_api_key.pem
tenancy=ocid1.tenancy.oc1..<unique_ID>
region=us-ashburn-1

The default location is ~/.oci/config; in PowerShell it is $Env:UserProfile\.oci\config. The key must be PEM, RSA with at least 2048 bits, and it is not the SSH key for your instances. The pass_phrase entry exists for encrypted keys, but Oracle marks it as deprecated and recommends passing the passphrase at runtime.

With the CLI: oci setup config

If you would rather not use the Console for the file, oci setup config asks for the OCIDs and the region, generates the key pair and writes the file. What it does not do is upload the public key: that is still Add API Key → Paste a public key in the Console, and that is where the fingerprint appears. To compare your local key's fingerprint with the Console's, Oracle gives this OpenSSL command:

# asks for OCIDs and region, generates the keys and writes ~/.oci/config
oci setup config

# fingerprint of the local private key: it must match the Console's
openssl rsa -pubout -outform DER -in ~/.oci/oci_api_key.pem | openssl md5 -c

# only you should be able to read the key
chmod go-rwx ~/.oci/oci_api_key.pem

Test that it authenticates

# regions the tenancy is subscribed to (and which one is home)
oci iam region-subscription list

# details of the user who owns the key
oci iam user get --user-id ocid1.user.oc1..<unique_ID>

If either one returns data, the signature is valid: the user OCID, fingerprint, key and tenancy are right. A NotAuthorizedOrNotFound (404) is something else: it authenticated, but the policy of the user's group does not let it see that resource.

NotAuthenticated (401): the causes Oracle lists

Oracle documents 401 NotAuthenticated as "The required authentication information was not provided or was incorrect", and lists these causes:

The clock is quick to rule out by comparing your UTC time with the Date header any API endpoint returns:

date -u
# the Date header of the API endpoint you are using
curl -s --head <endpoint> | grep Date

Frequently asked questions about the tenancy OCID and user OCID

Where is the tenancy OCID in the OCI Console? In the Profile menu, top right → Tenancy: <your tenancy name>, under Tenancy Information. Show displays it in full and Copy copies it. It starts with ocid1.tenancy.oc1...

Is the tenancy OCID the same as the root compartment OCID? Yes: the root compartment is the tenancy, so its OCID is the tenancy OCID. Other compartments have their own, under Identity & Security → Identity → Compartments.

What is the API key fingerprint and where do I see it? It identifies which of the user's keys signs the request (Oracle allows up to three API keys per user). The Console shows it when you upload the public key, and openssl rsa -pubout -outform DER -in ~/.oci/oci_api_key.pem | openssl md5 -c gives your local key's, which must match.

What Control Cloud asks for

Control Cloud's OCI form asks for four values: tenancy OCID, user OCID, fingerprint and the private key content, pasted (not the file path). It does not ask for a region or a compartment. With that key it lists the tenancy's subscribed regions, starts by reading the home region, and the others are enabled from the app; which compartments and resources it sees depends on the policy of the user's group, which the OCI guide sets up as read-only. Credentials are stored encrypted. If you want to try it with your tenancy, sign in free with your Google account.

Sources

Step-by-step guide: OCI API key: how to create one with read-only access