> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackone.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect Snowflake with Key Pair – StackOne Hub

> Link a Snowflake account in the StackOne Hub using Key Pair. End-user guide to authorize the integration and start using Snowflake actions.

> [!WARNING]
>
> ACCOUNTADMIN or equivalent privileges are required to assign a public key to a Snowflake user.

## How key pair authentication works

Key pair authentication uses an RSA key pair that you generate yourself.

<ul>
  <li>**Private key** (`rsa_key.p8`) — generated locally with OpenSSL. If you lose it, it cannot be recovered from Snowflake or the public key, so generate a new key pair and re-register the public key.</li>
  <li>**Public key** (`rsa_key.pub`) — registered on your Snowflake user via `ALTER USER`.</li>
</ul>

## Find your Account Identifier

Your **Account Identifier** uniquely identifies your Snowflake account and routes API requests to it.

**1. Copy the Account Identifier**

Sign in to your [Snowflake account](https://app.snowflake.com) and click your **user profile** (showing your username and role) in the bottom-left corner of the sidebar.

<ul>
  <li>In the menu that opens, click your account entry (e.g., **Account: AB12345**) to expand the account submenu.</li>
  <li>Select **View account details**.</li>
  <li>Copy the **Account Identifier** shown in the dialog.</li>
  <li>Format: `orgname-accountname` (e.g., `myorg-account123`)</li>
  <li>Alternative — run `SELECT CURRENT_ORGANIZATION_NAME() || '-' || CURRENT_ACCOUNT_NAME();` in any worksheet</li>
</ul>

## Find your username

Your **Username** is the Snowflake user the public key will be assigned to.

<ul>
  <li>Run `SELECT CURRENT_USER();` in any worksheet to see the user you are signed in as</li>
  <li>Or navigate to **Governance & security** > **Users & roles** in Snowsight to pick a dedicated service user.</li>
  <li>Casing does not matter.</li>
</ul>

## Generate an RSA key pair

Snowflake key-pair authentication uses a 2048-bit RSA key pair that you generate yourself with OpenSSL. Run these commands in your terminal.

**1. Generate the private key**

Run the following command to generate an unencrypted private key in PKCS8 format.

```bash theme={null}
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocrypt
```

<ul>
  <li>This creates `rsa_key.p8`. Copy the **RSA Private Key (PKCS8 PEM)** across with its entire contents, including the BEGIN and END marker lines.</li>
</ul>

**2. Extract the public key**

Run the following command to extract the public key from the private key.

```bash theme={null}
openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub
```

<ul>
  <li>This creates `rsa_key.pub`, the public key you assign to your Snowflake user.</li>
</ul>

## Assign the public key to your Snowflake user

The public key goes on the same Snowflake user as your **Username**.

**1. Assign the key to your user**

Open `rsa_key.pub` and copy the content between (but not including) the `-----BEGIN PUBLIC KEY-----` and `-----END PUBLIC KEY-----` lines.\
\
In a Snowflake worksheet, switch to a role with permission to alter the user, then run the ALTER USER statement, replacing `<username>` with your **Username** and `<public_key_body>` with the value you copied.

```sql theme={null}
USE ROLE ACCOUNTADMIN;
ALTER USER <username> SET RSA_PUBLIC_KEY='<public_key_body>';
```

<ul>
  <li>The key body is the long base64 block from `rsa_key.pub`, pasted as a single quoted string (line breaks within it are allowed).</li>
</ul>

**2. Verify the key assignment**

Confirm the public key is registered on the user before connecting.

```sql theme={null}
DESC USER <username>;
```

<ul>
  <li>Check that the `RSA_PUBLIC_KEY_FP` property now shows a `SHA256:...` fingerprint value.</li>
</ul>

## Link the Account

**1. Connect**

<ul>
  <li>Click **Connect**.</li>
  <li>If applicable, the provider will redirect you to a sign-in or authorization page. Complete the provider's authorization flow.</li>
  <li>Once authorization is successful, you will see a confirmation popup.</li>
</ul>

**2. Use Actions**

Connect an AI platform to the linked account's actions. See [AI Platforms](https://docs.stackone.com/ai-platforms/overview.md).

Other ways to call actions are listed in [Protocols & SDKs](https://docs.stackone.com/connect/protocols-and-sdks.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.