RSA Key-pair
Steps to Generate and Register a Key Pair in Snowflake
Steps to generate and register a key pair in Snowflake
Step 1: Generate and secure RSA key pair
Run the following command sequence to generate an RSA key pair in one step:
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.pubWhen you run the command sequence above, you are prompted for three passwords in order:
Encryption password: A new password to encrypt the private key.
Verify encryption password: Re-enter the same password to confirm.
Passphrase prompt: The passphrase that decrypts the private key during authentication. An unencrypted private key does not require a passphrase.
You can use the same password for all three prompts. Note down the passphrase securely. You need it later when configuring Snowflake authentication.
Step 2: Retrieve the private key
Run the following command to display the private key contents. You use these contents when creating the Secret.
Step 3: Retrieve the public key for Snowflake
Display the public key as a single line to register in Snowflake:
Copy the output string and use it in the next step.
Step 4: Register the public key in Snowflake
Use a Snowflake account with appropriate privileges such as ACCOUNTADMIN or SECURITYADMIN, then run:
Verify that your public key has been registered successfully:
Step 5: (Optional) Verify the key fingerprint
To verify that your registered public key matches your local key, generate a fingerprint:
Compare the fingerprint with the RSA_PUBLIC_KEY_FP in Snowflake (from DESC USER). They must match for authentication to succeed.
Step 6: Rotate keys (recommended practice)
Snowflake supports two public keys (RSA_PUBLIC_KEY and RSA_PUBLIC_KEY_2) for key rotation.
Generate a new key pair.
Register the new public key:
Update your DataOS Instance Secret with the new private key.
Remove the old key after successful validation:
Last updated
Was this helpful?