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_KEYandRSA_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:
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
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.
Generate a new key pair.
Register the new public key as
RSA_PUBLIC_KEY_2:
Update Nilus and other clients to use the new private key.
Remove the old key:
Example: working depot
Security best practices
Restrict file permissions for key storage (
chmod 600on 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?