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
User OCID (ocid1.user.oc1..): Profile menu, top right → User settings. It is under User Information, with a Copy button. If you are an administrator looking for another user's: Identity & Security → Identity → Users, then the user's name.
Tenancy OCID (ocid1.tenancy.oc1..): Profile menu → Tenancy: <your tenancy name>. It is under Tenancy Information; Show displays it in full and Copy copies it.
Compartment OCID: Identity & Security → Identity → Compartments. The list shows a shortened OCID next to each compartment; one click shows the full value, with its Copy. The root compartment is the tenancy, so its OCID is the tenancy OCID.
Fingerprint: the Console shows it when you upload the public key to the user, in the form 12:34:56:78:90:ab:cd:ef:.... It identifies which of the user's keys signs the request: Oracle allows up to three API keys per user.
Region: an identifier such as us-ashburn-1. The configuration snippet the Console builds uses the region you had selected at that moment, not necessarily the home region.
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.
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:
A value that is missing or wrong: tenancy OCID, user OCID, fingerprint or private key. The typical case is the OCID of a different user, not the one the key was uploaded for.
key_file points to the public key instead of the private one.
A key pair in the wrong format: it must be PEM, not ssh-rsa.
The public key for that fingerprint is not uploaded for the signing user (or someone deleted it).
The tenancy is not subscribed to the region set in region.
The user is not in a group with the permissions the operation needs.
The machine's clock is more than five minutes off from the server's.
In custom clients, a piece of the signature's Authorization header is missing or malformed.
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
Oracle, "Required Keys and OCIDs" (generating and uploading the API key, fingerprint, tenancy and user OCIDs).
Oracle, "SDK and CLI Configuration File" (fields and location of ~/.oci/config).
Oracle, "Installing the CLI" (oci setup config and verifying the file) and the reference for oci iam region-subscription list and oci iam user get.