---
title: "SSH keys"
description: "The SSH keys NHI Security discovers through GitHub, GitLab, AWS, Google Cloud and Azure, what it records about each, and the findings that apply."
keywords: ["SSH keys", "deploy keys", "EC2 key pairs", "GCP metadata SSH keys", "Azure SSH public keys", "weak SSH key", "reused SSH key", "SSH key fingerprint"]
---

An SSH key that a provider holds on behalf of a machine, a pipeline or a repository is a non-human identity: it authenticates as itself, and whoever holds the private half has what it grants. NHI Security inventories these keys as identities of kind **SSH key**, so ownership, findings and access reviews apply to them as they do to any other identity.

NHI Security reads public keys only. It derives the algorithm, the size and the SHA-256 fingerprint (the value `ssh-keygen -l` prints) and does not store the public key itself. It never sees a private key, never logs in with a key, and does not rotate or revoke one.

## Where keys come from

Every source except GitLab is off by default, so an existing connector's credential keeps working until you turn it on and grant the extra permission.

| Connector | Setting | Keys | What a key is recorded as granting | Extra permission |
|---|---|---|---|---|
| GitHub | `includeDeployKeys` | Each repository's deploy keys | Read, plus write when the key is not read-only, on its repository | Repository **Administration: read** |
| GitLab | always | Project deploy keys | Read, plus write where `can_push` is set | none |
| AWS | `includeEc2KeyPairs` | EC2 key pairs in the connector's region | SSH login on each live instance EC2 records as launched with the key | `ec2:DescribeKeyPairs`, `ec2:DescribeInstances` |
| Google Cloud | `includeSshKeys` | `ssh-keys` lines in project and instance metadata | SSH login on each instance Google would accept the key on (project keys respect `block-project-ssh-keys` and OS Login) | `compute.projects.get`, `compute.instances.list` (in `roles/compute.viewer`) |
| Microsoft Entra ID (Azure) | `includeSshKeys` with `subscriptionId` | SSH public key resources (`Microsoft.Compute/sshPublicKeys`) in one subscription | SSH login on each VM provisioned with the same key | **Reader** on the subscription |

The created and last-used dates are recorded where the provider reports them: GitHub gives both, GitLab and EC2 give a creation date, Google Cloud metadata gives neither. GitHub's `added_by` and Google's own `google-ssh` annotation become owner suggestions, never an assigned owner. Users' personal SSH keys are not collected: they are a person's credential, not a machine's.

OS Login keys on Google accounts are not read. Azure gives neither date for a key resource.

## Findings

| Policy | Raised when |
|---|---|
| `ssh_key_weak` | The key is DSA, or RSA shorter than 2,048 bits (high below 1,024 bits, which current OpenSSH refuses; medium otherwise). A key whose algorithm the provider did not report is *not assessable*, never "strong". |
| `ssh_key_write_on_many_repositories` | One deploy key can push to at least `minRepositories` repositories (3 by default). |
| `ssh_key_reused` | The same fingerprint is recorded on another identity: another deploy key, key pair or metadata entry. |

Two existing policies also apply to SSH keys: `stale_identity` when the provider reports a last use older than the threshold, and `owner_departed` when the key's owner has left. See [Findings and risk](/nhi-security/findings-and-risk#the-policy-catalogue).

## In the console

**Identities** filters by kind; choose **SSH key**. A key's credential shows its fingerprint, algorithm and size, and its permissions show the repositories or instances it reaches. An [access review](/nhi-security/access-reviews) can be scoped to the **SSH key** kind alone.

## How this was verified

Each connector's SSH key reading is tested against provider responses written to each API's documented response shape, with throwaway public keys whose fingerprints were checked against `ssh-keygen`. None has been run against a live GitHub organization, GitLab instance, AWS account, Google Cloud project or Azure subscription.
