# Key Pair Authentication

{% stepper %}
{% step %}
**Generate an Unencrypted or Encrypted Private Key**

* Unencrypted Private Key:

{% code overflow="wrap" %}

```sh
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocrypt
```

{% endcode %}

* Encrypted Private Key:

{% code overflow="wrap" %}

```sh
openssl genrsa 2048 | openssl pkcs8 -topk8 -v2 des3 -inform PEM -out rsa_key.p8
```

{% endcode %}
{% endstep %}

{% step %}
**Generate a Public Key**

```sh
openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub
```

{% endstep %}

{% step %}
**Assign the public key to a Snowflake user**

```sql
ALTER USER TELESKOPE_USER SET RSA_PUBLIC_KEY='MIIBIjANBgkqh...';
```

{% hint style="info" %}
Exclude the public key delimiters in the SQL statement.
{% endhint %}
{% endstep %}

{% step %}
**Verify the user’s public key fingerprint**

1. Retrieve the User's Public Key Fingerprint **(In Snowflake)** and note the output:

```sql
DESC USER TELESKOPE_USER
  ->> SELECT SUBSTR(
        (SELECT "value" FROM $1
           WHERE "property" = 'RSA_PUBLIC_KEY_FP'),
        LEN('SHA256:') + 1) AS key;
```

2. Run the following command on **command line:**

{% code overflow="wrap" %}

```sh
openssl rsa -pubin -in rsa_key.pub -outform DER | openssl dgst -sha256 -binary | openssl enc -base64
```

{% endcode %}

3. Compare the outputs. If both outputs match, the user correctly configured their public key. Go back to the **Enrollment** step on the [previous page](/connectors/saas/snowflake.md) to complete enrollment.
   {% endstep %}
   {% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.teleskope.ai/connectors/saas/snowflake/key-pair-authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
