Skip to content

Oracle Cloud Infrastructure (OCI) Authentication

DRACO authenticates to Oracle Cloud Infrastructure (OCI) with an API key of an OCI user: the user OCID, the tenancy OCID, the key fingerprint, the private key and the region, entered in the provider form (see Getting started).

API Key Authentication

Setting Up API Keys

Option A: Generate API Key Using OCI Console (Simpler)

  1. Log in to OCI Console
  2. Navigate to Identity → Users → Select your user
  3. In the Resources section, click API Keys
  4. Click Add API Key
  5. Select Generate API Key Pair
  6. Click Download Private Key - save this file as ~/.oci/oci_api_key.pem
  7. Click Add
  8. The console will display a configuration file preview with:
  9. user OCID
  10. fingerprint
  11. tenancy OCID
  12. region

  13. Copy the entire configuration snippet from the console and paste it into ~/.oci/config

  14. Add the key_file parameter pointing to your downloaded private key:
[DEFAULT]
user=ocid1.user.oc1..aaaaaaaexample
fingerprint=11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:11
tenancy=ocid1.tenancy.oc1..aaaaaaaexample
region=us-ashburn-1
key_file=~/.oci/oci_api_key.pem  # Add this line
  1. Set proper permissions:
    chmod 600 ~/.oci/oci_api_key.pem
    chmod 600 ~/.oci/config
    

Option B: Generate API Key Manually

  1. Generate the key pair locally:
mkdir -p ~/.oci
openssl genrsa -out ~/.oci/oci_api_key.pem 2048
chmod 600 ~/.oci/oci_api_key.pem
openssl rsa -pubout -in ~/.oci/oci_api_key.pem -out ~/.oci/oci_api_key_public.pem
  1. Upload the public key to OCI Console:
  2. Navigate to Identity → Users → Select your user
  3. In the Resources section, click API Keys
  4. Click Add API Key
  5. Select Paste Public Key or Choose Public Key File
  6. Paste or upload the contents of ~/.oci/oci_api_key_public.pem
  7. Click Add

  8. The console will display the configuration file preview with your user OCID, fingerprint, tenancy OCID, and region.

  9. Copy the configuration snippet from the console and create ~/.oci/config:

[DEFAULT]
user=<user_ocid_from_console>
fingerprint=<fingerprint_from_console>
tenancy=<tenancy_ocid_from_console>
region=<region_from_console>
key_file=~/.oci/oci_api_key.pem
  1. Set proper permissions:
    chmod 600 ~/.oci/config
    chmod 600 ~/.oci/oci_api_key.pem
    

Security Best Practices

API Key Security

  1. Rotate API Keys Regularly
  2. OCI recommends rotating API keys every 90 days
  3. DRACO includes a check for this: identity_user_api_keys_rotated_90_days

  4. Use Separate Keys Per Environment

  5. Development, staging, and production should use different API keys
  6. Use profiles to manage multiple environments

  7. Restrict Key Permissions

  8. Follow the principle of least privilege
  9. Grant only read permissions for security auditing

  10. Secure Key Storage

    chmod 600 ~/.oci/oci_api_key.pem
    chmod 600 ~/.oci/config
    

  11. Never Commit Keys to Version Control

  12. Add ~/.oci/ to .gitignore
  13. Use secret management systems for automation

Troubleshooting

Permission Errors

Error: "Authorization failed or requested resource not found"

Cause: Insufficient IAM permissions

Solution: Add required policies (see the OCI IAM policies documentation)

Additional Resources