For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

Snowflake key-pair authentication

Step-by-step guide to Snowflake key-pair authentication for Nilus: generating and registering RSA keys, depot configuration, and key rotation.

This page covers how key-pair authentication works, how to generate and register your keys in Snowflake, and how to connect securely from Nilus.

Snowflake supports key-pair authentication as a password-less alternative to username/password credentials. With key-pair authentication:

  • You create a public/private RSA key pair locally.

  • You register the public key with your Snowflake user.

  • The Nilus connector (or any client) signs authentication tokens with the private key, and Snowflake verifies them using the registered public key.

Benefits

  • Removes passwords from application configurations.

  • Supports key rotation through dual public key support (RSA_PUBLIC_KEY and RSA_PUBLIC_KEY_2).

  • Supported across Snowflake’s Python, JDBC, ODBC, and CLI clients.

Generating a key pair

Create a secure directory and generate your key pair in PKCS#8 PEM format. Encrypted private keys are recommended.

mkdir -p ~/.snowflake/keys
cd ~/.snowflake/keys

# Generate encrypted private key (recommended)
openssl genrsa 2048 | openssl pkcs8 -topk8 -v2 des3 -inform PEM -out snowflake_rsa_key.p8

# Or, unencrypted private key (not recommended)
# openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out snowflake_rsa_key.p8 -nocrypt

# Extract public key
openssl rsa -in snowflake_rsa_key.p8 -pubout -out snowflake_rsa_key.pub

# Secure file permissions
chmod 700 ~/.snowflake ~/.snowflake/keys
chmod 600 ~/.snowflake/keys/snowflake_rsa_key.p8 ~/.snowflake/keys/snowflake_rsa_key.pub

To retrieve the public key for Snowflake:

(Optional) Generate a fingerprint for verification:
  • It computes a SHA‑256 fingerprint of your public key so you can verify it matches what Snowflake stored.

Breakdown of the pipeline:

  • openssl rsa -pubin -in ... -outform DER: loads your PEM public key and converts it to binary DER.

  • | openssl dgst -sha256 -binary: computes the raw SHA‑256 hash (digest) of that DER.

  • | openssl enc -base64: base64‑encodes the digest into a readable string.

How to use it:

  • Compare the command’s output to RSA_PUBLIC_KEY_FP from DESC USER <user> after removing the SHA256: prefix. They must match; if not, the bound key and your local key differ.

Reference: Snowflake key‑pair auth and fingerprint verification steps docs.

Registering the public key in Snowflake

You’ll need a role with privileges to modify users (e.g., ACCOUNTADMIN, SECURITYADMIN, or a custom role with MODIFY PROGRAMMATIC AUTHENTICATION METHODS).

Verify your setup:

Troubleshooting

Issue
Cause / Resolution

JWT token is invalid

The private key used by the client doesn’t match the public key on the Snowflake user.

Insufficient privileges

The active role cannot modify the user; switch to ACCOUNTADMIN or equivalent.

Testing a key-pair connection (Python example)

Notes

  • No password is required when using key-pair authentication.

  • If you used an encrypted private key, confirm your client can provide the passphrase.

Configuring a Snowflake depot for Nilus

When defining a Snowflake depot in Nilus, include your private key under connectionSecret.data.key.

⚠️ Important: Keep private keys out of version control and shared files.

Key rotation

Snowflake supports dual public keys per user for rotation.

  1. Generate a new key pair.

  2. Register the new public key as RSA_PUBLIC_KEY_2:

  1. Update Nilus and other clients to use the new private key.

  2. Remove the old key:

Example: working depot

Security best practices

  • Restrict file permissions for key storage (chmod 600 on private keys).

  • Prefer encrypted private keys with strong passphrases.

  • Use a dedicated secret management system where possible.

  • Rotate keys periodically and audit access.

Last updated

Was this helpful?