# 14 SSH Key Management Best Practices Every Developer Needs in 2026
URL: https://ctrlops.io/blog/ssh-key-management-best-practices
Author: Hiren Kalariya | Role: Co-Founder & CEO, TST Technology | Category: SSH & Remote Access | Published: 2026-06-01 | Updated: 2026-11-10 | Tags: ssh key management, ssh keys, ed25519, ssh security, devops | Reading time: 33 min

> SSH key management best practices for 2026: Ed25519 keys, passphrases, per-user access, key rotation, same-day revocation and a 90-day audit, with commands.

SSH key management best practices come down to six habits: create Ed25519 keys with a passphrase, give every person and every machine its own key, keep private keys on your own devices, rotate automation keys every 90 days, remove a person's key the same day they leave, and audit every server's `authorized_keys` file every 90 days. The 14 practices in this guide follow the full key lifecycle, from `ssh-keygen` to revocation, with the exact OpenSSH commands for each step.

*Disclosure: CtrlOps is our product. Every practice gives the plain OpenSSH commands first. CtrlOps appears only where it saves steps, and its limits are listed in the tools section.*

We ran these commands on Ubuntu 24.04 LTS (OpenSSH 9.6p1) in November 2026 and checked key generation and key exchange on macOS 26 (OpenSSH 10.3p1); the macOS Keychain, FIDO2 and Windows steps follow vendor docs.

The usual story: a client sends server access over Slack, you add a key, the project ends, and the key stays on the server for years. [Freelancers](https://ctrlops.io/for/freelancers) with 8 to 12 client servers and startup CTOs whose former developers can still reach production know it well.

> **TL;DR**
>
> - **Freelancers:** one key per client and per laptop (a stolen laptop exposes one client, not twelve).
> - **Startup CTOs:** one key per person, removed the day they leave (shared keys never get replaced).
> - **CI/CD and cron jobs:** a separate passphrase-free key, locked to one task and rotated every 90 days (nothing else protects it).
> - **Compliance-sensitive teams:** private keys stay on your own devices (NDAs and SOC 2 ask where secrets live).
> - **Everyone:** Ed25519 keys with a passphrase and an `authorized_keys` audit every 90 days (unknown keys pile up).

Prefer to watch? All 14 practices in under 6 minutes:

Video: https://www.youtube.com/watch?v=LOjVvJ1owCU

---

## What Are SSH Key Management Best Practices?

SSH key management best practices are the rules for the five stages of an SSH key's life: how you create it, where you store it, who gets it, how often you replace it and how fast you remove it. [NIST IR 7966](https://csrc.nist.gov/pubs/ir/7966/final) puts the goal in one line: SSH access "requires proper provisioning, termination, and monitoring processes."

The 14 practices cover those stages in order: generate (1 to 3), rotate (4), store and name (5 and 6), distribute (7 and 8), revoke and audit (9 to 11), then troubleshoot and scale (12 to 14). The cryptography in OpenSSH is rarely the weak point; the usual gaps are a key nobody removed, a laptop key with no passphrase, or one team key shared by ten people.

---

## The 14 SSH Key Management Best Practices

The 14 practices follow the key lifecycle in order, and each one starts with the OpenSSH command. Practices 1 to 12 apply to every developer or small team managing Linux servers. Practices 13 and 14 (FIDO2 hardware keys and SSH certificates) cover advanced setups for teams whose needs go beyond plain key files.

![14 SSH key management best practices every developer must follow in 2026](https://cdn.ctrlops.io/blog/ssh-key-management-best-practices/14-SSH-Key-Management-Best-Practices-Every-Developer-Must-Follow.webp)

### Practice 1: Use ssh-keygen to Create Ed25519 Keys, Not RSA 2048

Ed25519 is the recommended type for every new OpenSSH key: short keys, fast signing, and a design that resists several implementation-level attacks. RSA 2048 is still secure but no longer the best choice; keep RSA for systems that require it, at 4096 bits.

![Ed25519 vs RSA SSH key comparison showing key size, connection speed, and security level for choosing the right SSH key type in 2026](https://cdn.ctrlops.io/blog/ssh-key-management-best-practices/Ed25519-vs-RSA_-Which-SSH-Key-Should-You-Use-in-2026_.webp)

#### Why Ed25519 Is Preferred Over RSA For New Deployments

| Property | Ed25519 | RSA 2048 | RSA 4096 |
|---|---|---|---|
| Key size | 256 bits | 2048 bits | 4096 bits |
| Signatures per second (our test) | About 57,600 | About 2,900 | About 460 |
| Security level | Similar to RSA 3072 | Acceptable for most current use cases | Acceptable |
| Side-channel resistance | High (by design) | Depends on the implementation | Depends on the implementation |
| Support | OpenSSH 6.5 (2014) and newer | Universal | Universal |
| Verdict | Use this | Avoid for new keys | Only if Ed25519 is unsupported |

In our `openssl speed` test (OpenSSL 3.0.13, Ubuntu 24.04, Apple Silicon), Ed25519 signed about 20 times faster than RSA 2048, but RSA checks signatures faster and a login needs one signature, so you won't feel it. Switch for the design: the [Ed25519 authors](https://ed25519.cr.yp.to/) give it a 2^128 security target, similar to RSA with about 3,000-bit keys, and the code never branches on secret data. [Mozilla's OpenSSH Guidelines](https://infosec.mozilla.org/guidelines/openssh) list the Ed25519 host key first.

**Generate an Ed25519 key:**

```bash
ssh-keygen -t ed25519 -C "your-comment-here"
```

Replace `your-comment-here` with the naming pattern from Practice 6, such as `emily@macbook-pro-2026-11`. For a genuinely old server that predates OpenSSH 6.5, fall back to RSA 4096, never a new RSA 2048 key:

```bash
ssh-keygen -t rsa -b 4096 -C "your-comment-here"
```

**With CtrlOps SSH Setup Wizard:** In the left sidebar, under TOOLS, click SSH Setup. The wizard recommends Ed25519, generates the pair in one click, and shows your new key ready to copy. See the [SSH Setup Wizard documentation](https://ctrlops.io/docs/modules/ssh-management#generate-an-ssh-key-gui-wizard) for step-by-step details.

Adding, viewing and removing keys in CtrlOps:

Video: https://www.youtube.com/watch?v=hFpXnR8AGYA

> Use Ed25519 for every new key. If a platform says it supports only RSA, check again: OpenSSH has supported Ed25519 since version 6.5 in 2014.

**Need a key on a machine without ssh-keygen?**

Our free SSH key generator creates Ed25519 or RSA key pairs in your browser with the Web Crypto API, so the private key is never sent over the network.

#### Use Modern SSH Key Exchange Algorithms (Including Post-Quantum)

SSH key exchange (KEX) is the handshake at the start of every connection, where both sides agree on a session key; it is a separate setting from your key type. Post-quantum key exchange is now the OpenSSH default, but old servers and copied configs can still allow weak methods such as `diffie-hellman-group1-sha1`, disabled by default since OpenSSH 7.0.

![Modern SSH connection flow diagram showing the key exchange handshake and post-quantum KEX negotiation between an SSH client and server](https://cdn.ctrlops.io/blog/ssh-key-management-best-practices/Modern-SSH-Connection-Flow.webp)

**Which key exchange methods to keep:**

| KEX Algorithm | Status | Notes |
|---|---|---|
| `diffie-hellman-group1-sha1` | ✗ Remove immediately | 1024-bit DH, too weak for 2026 |
| `diffie-hellman-group14-sha1` | ✗ Remove | SHA-1, flagged by most security scanners |
| `diffie-hellman-group-exchange-sha256` | ✓ Keep | Fallback for older clients; Mozilla's modern config lists it |
| `curve25519-sha256` | ✓ Keep | Classical baseline, fast and secure |
| `sntrup761x25519-sha512` | ✓ Keep | Post-quantum hybrid, default since OpenSSH 9.0 (named `sntrup761x25519-sha512@openssh.com` before 9.9) |
| `mlkem768x25519-sha256` | ✓ Preferred | NIST-standardized post-quantum hybrid, added in 9.9, default since 10.0 |

**The post-quantum context:** OpenSSH 9.0 (April 2022) made the hybrid `sntrup761x25519-sha512@openssh.com` the default, and OpenSSH 10.0 (April 2025) moved to `mlkem768x25519-sha256`. [GitHub added post-quantum key exchange](https://github.blog/engineering/platform-security/post-quantum-security-for-ssh-access-on-github/) for Git over SSH on GitHub.com on September 17, 2025. Since [OpenSSH 10.1](https://www.openssh.com/releasenotes.html), a connection without it prints a warning: `This session may be vulnerable to "store now, decrypt later" attacks.` Your job is removing weak fallbacks with a line your version understands, because one name it doesn't know makes `sshd` refuse the whole file.

**Harden your KEX configuration in `/etc/ssh/sshd_config`:**

```bash
# 1. Check the OpenSSH version and the key exchange methods it supports
ssh -V
ssh -Q kex

# 2. Add ONE of these lines to /etc/ssh/sshd_config
# OpenSSH 9.9 or newer:
KexAlgorithms mlkem768x25519-sha256,sntrup761x25519-sha512,curve25519-sha256,diffie-hellman-group-exchange-sha256
# OpenSSH 8.5 to 9.8 (Ubuntu 24.04 ships 9.6p1):
KexAlgorithms sntrup761x25519-sha512@openssh.com,curve25519-sha256,diffie-hellman-group-exchange-sha256
# OpenSSH 7.4 to 8.4:
KexAlgorithms curve25519-sha256,diffie-hellman-group-exchange-sha256

# 3. Test the file before you restart: sshd won't start with an error in it
sudo sshd -t

# 4. Restart SSH: the service is "ssh" on Ubuntu and Debian, "sshd" on RHEL, Fedora and Arch
sudo systemctl restart ssh

# 5. Check that a weak method is refused
ssh -oKexAlgorithms=diffie-hellman-group1-sha1 localhost
# Expected: "no matching key exchange method found"
```

Keep a second SSH session open until the new settings work. For the full recommendations, see [Mozilla's OpenSSH Guidelines](https://infosec.mozilla.org/guidelines/openssh) and [openssh.org/pq.html](https://www.openssh.org/pq.html), and paste the whole file into the free [sshd_config Analyzer](https://ctrlops.io/tools/sshd-config-analyzer), which grades the config A to F and shows the line that fixes each weak directive.

> Key type and key exchange are separate settings: a server with Ed25519 keys that still allows `diffie-hellman-group1-sha1` is only half-hardened. Remove the weak fallbacks with a line your version understands, and run `sudo sshd -t` before every restart.

---

### Practice 2: One Key Pair Per Machine, Per Use Case

Never reuse a private key across machines or purposes. Give each laptop, each client and each automation job its own key pair, so a compromised key exposes one machine's worth of access, not every server you manage.

![One key pair per machine per use case architecture with separate Ed25519 keys for each laptop and client mapped in the SSH config file](<https://cdn.ctrlops.io/blog/ssh-key-management-best-practices/One-Key-Per-Machine,-Per-Use-Case-Architecture.webp>)

#### Common key separation patterns

```
~/.ssh/
├── id_ed25519                # Personal laptop, default key
├── id_ed25519.pub
├── client_acme_ed25519       # Client A, freelance project
├── client_acme_ed25519.pub
├── client_beta_rsa4096       # Client B, legacy server that needs RSA
├── client_beta_rsa4096.pub
├── ci_deploy_ed25519         # CI/CD only, no passphrase (Practice 3)
├── ci_deploy_ed25519.pub
└── config
```

Your other devices get their own sets. Map each key to the right servers in `~/.ssh/config`:

```
Host acme-prod
  HostName 203.0.113.10
  User ubuntu
  IdentityFile ~/.ssh/client_acme_ed25519
  IdentitiesOnly yes
  AddKeysToAgent yes

Host beta-staging
  HostName 198.51.100.20
  User ec2-user
  IdentityFile ~/.ssh/client_beta_rsa4096
  IdentitiesOnly yes
```

Now `ssh acme-prod` picks the right key, and `IdentitiesOnly yes` stops SSH from offering every agent key to every server ("Too many authentication failures"). The [SSH Config Generator](https://ctrlops.io/tools/ssh-config-generator) builds these blocks for multi-client setups, bastion hosts and port forwarding.

**For a freelancer with 10 client servers,** this decides how bad a lost laptop gets: one key for everything exposes all 10 clients, one key per client exposes one, and you know which key to revoke.

![SSH key chaos vs organized SSH management: scattered, unlabeled SSH keys on the left versus a clean per-client key structure with clear names on the right](https://cdn.ctrlops.io/blog/ssh-key-management-best-practices/SSH-Key-Chaos-vs-Organized-SSH-Management.webp)

**When a project ends:** unload the key with `ssh-add -d ~/.ssh/client_acme_ed25519`, remove your public key from the client's `authorized_keys`, and archive or delete the local key pair. For day-to-day work across many client servers, read the guide on [managing multiple servers without losing control](https://ctrlops.io/blog/manage-multiple-servers-without-losing-control).

> **Reality check:** "One key for everything" is the most common SSH key mistake. If that one key is stolen and cracked, every server you ever added it to is open. Separate keys are damage control, not paranoia.

---

### Practice 3: Protect Every Private Key with a Passphrase

A passphrase encrypts the private key on disk, so a copied file is useless without it.

Generate a key with a passphrase:

```bash
ssh-keygen -t ed25519 -C "emily@macbook-pro-2026-11"
```

The tool prompts:

```
Enter passphrase (empty for no passphrase): [type a strong passphrase]
Enter same passphrase again: [confirm]
```

Use four to six random words, not a variation of your login password. **To avoid re-typing it all day,** add your key to the SSH agent once per session:

```bash
ssh-add ~/.ssh/id_ed25519
```

On macOS, persist it across reboots:

```bash
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
```

The agent holds the decrypted key in memory, so you type the passphrase once and the key is never written to disk unencrypted.

#### How to Remove a Passphrase from an Automation Key

CI/CD pipelines, cron jobs and deploy scripts run unattended and can't type a passphrase. Give them their own key without one, and never strip the passphrase from your personal key.

**Remove a passphrase from an existing key:**

```bash
ssh-keygen -p -f ~/.ssh/ci_deploy_ed25519
```

The tool prompts:

```
Enter old passphrase: [current passphrase]
Enter new passphrase (empty for no passphrase): [press Enter]
Enter same passphrase again: [press Enter]
Your identification has been saved with the new passphrase.
```

Pressing Enter for the new passphrase sets it to empty, which removes it.

**Correct workflow for automation keys:**

1. Generate a dedicated key: `ssh-keygen -t ed25519 -C "deploy@github-actions-2026-11" -f ~/.ssh/ci_deploy_ed25519`
2. Leave the passphrase empty, or remove it later with `ssh-keygen -p`
3. Add only this key's public key to the target server
4. Lock it to one task in `authorized_keys`: `restrict` turns off forwarding and terminals, and `command=` runs one fixed command whatever the client asks for: `restrict,command="/usr/local/bin/deploy.sh" ssh-ed25519 AAAA... deploy@github-actions-2026-11`
5. Rotate it every 90 days or when a project ends (Practice 4)

> **Reality check:** A passphrase-free deploy key is an accepted tradeoff only when it is scoped tightly. If it can `sudo` into anything on production, a compromised CI system is a full production breach. In CtrlOps, the [Add User](https://ctrlops.io/docs/modules/ssh-management#add-a-user-and-authorize-their-key) form handles that lockdown: give the key a Restricted role and tick `no-port-forwarding`, `no-agent-forwarding`, and `no-X11-forwarding`.

> A stolen key with a passphrase is useless; a stolen key without one is an instant compromise. Only dedicated, locked-down automation keys go without a passphrase.

---

### Practice 4: Rotate SSH Keys on a Schedule

To rotate an SSH key, add the new key, test it, then remove the old one, in that order, on every server and cloud account that trusted the old key. Rotate CI/CD and other automation keys every 90 days, personal keys once a year, and any key at once when someone leaves, a laptop goes missing or a key may have leaked.

| Key | When to rotate |
|---|---|
| CI/CD, cron and deploy keys | Every 90 days |
| A person's own key | Once a year |
| Any key | At once after an exit, a lost laptop or a leak |

**Find every place the old key works first.** Across cloud infrastructure, that includes AWS EC2 key pairs and DigitalOcean or Hetzner SSH key lists, which put the key on new servers, and CI secret stores. On each server, `ssh-keygen -lf ~/.ssh/authorized_keys` lists the fingerprints it trusts.

**Rotate one key in five commands:**

```bash
# 1. Make the new key on your computer, dated in the comment
ssh-keygen -t ed25519 -C "emily@macbook-pro-2026-11" -f ~/.ssh/id_ed25519_2026_11

# 2. Add it to the server, logging in with the old key
ssh-copy-id -i ~/.ssh/id_ed25519_2026_11.pub emily@203.0.113.10

# 3. Test the new key on its own
ssh -i ~/.ssh/id_ed25519_2026_11 -o IdentitiesOnly=yes emily@203.0.113.10 'echo new key works'

# 4. Remove the old key from the server, matched by its comment
ssh -i ~/.ssh/id_ed25519_2026_11 -o IdentitiesOnly=yes emily@203.0.113.10 "sed -i '/ emily@macbook-pro-2025-11\$/d' ~/.ssh/authorized_keys"

# 5. Check which keys the server still trusts
ssh -i ~/.ssh/id_ed25519_2026_11 -o IdentitiesOnly=yes emily@203.0.113.10 'ssh-keygen -lf ~/.ssh/authorized_keys'
```

Step 4 matches the old key by its comment (Practice 6); with no comment, match a unique piece of the key string. Then point `IdentityFile` in `~/.ssh/config` at the new key, unload the old one with `ssh-add -d`, and delete its files. For a CI/CD key, update the CI secret store before step 4.

**Contractors:** put OpenSSH's `expiry-time` option in front of the key, and the server refuses it after that date (OpenSSH 7.7+, server time zone unless you add `Z` for UTC):

```
expiry-time="20270131" ssh-ed25519 AAAA... lukas@acme-contract-2026-11
```

**With CtrlOps:** **Rotate SSH Key** in a person's [Access](https://ctrlops.io/features/access-management) panel runs steps 2 to 4 on every server they can reach: paste the new public key, and CtrlOps adds it, then removes the old key only where the new one went in. **Add User** in [SSH Management](https://ctrlops.io/docs/modules/ssh-management#add-a-user-and-authorize-their-key) can **Set an expiry**, which writes the same `expiry-time` option. There are no rotation reminders, so keep the dates in your calendar.

> **Bottom line**
>
Add, test, remove: never delete the old key before the new one works. Rotate automation keys every 90 days, personal keys once a year, and any key the same day someone leaves or a laptop goes missing.

---

### Practice 5: Keep Private Keys on Your Own Machine

Private key files (anything without `.pub`) stay on devices you control: not in Dropbox, Google Drive, iCloud or Notion, and never in a Git repository. [Wiz Research's November 2025 investigation of the Forbes AI 50](https://www.wiz.io/blog/forbes-ai-50-leaking-secrets) found verified secret leaks on GitHub at 65% of leading AI companies, buried in deleted forks, gists and commit history.

Set `chmod 700` on `~/.ssh` and `chmod 600` on every private key (the full list is in Practice 10). **For backup,** copy `~/.ssh/` to an encrypted drive or an end-to-end encrypted password manager, never as plain files to a cloud folder.

#### Which SSH Clients Sync Your Keys to the Cloud?

Some SSH clients keep credentials only on your computer; others sync them through their own cloud, usually encrypted. Both can be fine if you know which one you use when NDAs, SOC 2 or data residency rules apply.

**Termius** keeps everything in a local vault on its free Starter plan. Pro and higher plans (from $10/month, billed annually, on the [Termius pricing page](https://termius.com/pricing)) add a personal cloud vault that syncs across desktop and mobile, with [end-to-end encryption](https://termius.com/security) using a key derived from your password.

**1Password SSH Agent** keeps keys in your end-to-end encrypted 1Password vault, which syncs to your devices, and signs logins for your SSH client; in [1Password's words](https://developer.1password.com/docs/ssh/agent/), "your private key never even leaves the 1Password app."

**Cloud-hosted terminals** (browser-based SSH clients) route your session through the provider's servers by design, so your keystrokes pass through infrastructure you don't control.

**What to check** before adopting any SSH client for production use:

1. Does the tool store or sync private key material outside my machine?
2. Can I verify where credentials are stored (local filesystem vs. cloud vault vs. SaaS backend)?
3. Does the tool's architecture satisfy my clients' NDA or compliance requirements?

CtrlOps has no cloud sync: it keeps your key files where they are and saves only their paths, and saved server details and passwords are AES-256 encrypted on your computer. Read more about [CtrlOps' local-first SSH security architecture](https://ctrlops.io/docs/core/ssh-security).

> A private key synced as a plain file to a cloud folder is a copy you no longer control. Back up keys to an encrypted drive or an end-to-end encrypted vault, and know which one your SSH client uses.

---

### Practice 6: Add Key Comments with a Naming Convention

The `-C` flag adds a comment to the end of a public key. Most developers skip it, and a server's `authorized_keys` file ends up like this:

```
ssh-ed25519 AAAA...
ssh-ed25519 AAAA...
ssh-ed25519 AAAA...
```

Three keys, and no idea whose they are, when they were added, or which machine they came from.

**Use one naming pattern for every key, `who@device-YYYY-MM`:**

```bash
ssh-keygen -t ed25519 -C "emily@macbook-pro-2026-11"
ssh-keygen -t ed25519 -C "deploy@github-actions-2026-11"
ssh-keygen -t ed25519 -C "lukas@acme-contract-2026-11"
```

Now your `authorized_keys` reads:

```
ssh-ed25519 AAAA... emily@macbook-pro-2026-11
ssh-ed25519 AAAA... deploy@github-actions-2026-11
ssh-ed25519 AAAA... lukas@acme-contract-2026-11
```

The name says who to ask, the device which laptop to check after a loss, and the date when the key is due for rotation (Practice 4). Name key files by purpose: `client_acme_ed25519`, `ci_deploy_ed25519`. In CtrlOps' [SSH Management tab](https://ctrlops.io/docs/modules/ssh-management), the comment shows as the key's Public Key Identity.

> Comments cost nothing and save time at every revocation. `alex@dev-laptop-2026-11` tells you immediately whether to remove it when Alex leaves. A blank comment tells you nothing.

---

### Practice 7: Copy Keys to Servers Correctly, Not by Hand

Most developers do this once, under pressure, and never document it. Here are the three correct methods, fastest first.

#### Method 1 (Recommended): `ssh-copy-id`

When you already have password access to the server:

```bash
ssh-copy-id -i ~/.ssh/id_ed25519.pub username@your-server-ip
```

This appends your public key to `~/.ssh/authorized_keys` on the server, creates the `.ssh` directory if needed, and sets correct permissions, all automatically.

#### Method 2: Manual append

```bash
# Step 1: Copy your public key
cat ~/.ssh/id_ed25519.pub

# Step 2: SSH into the server
ssh username@your-server-ip

# Step 3: Create .ssh directory
mkdir -p ~/.ssh
chmod 700 ~/.ssh

# Step 4: Append the public key
echo "YOUR_PUBLIC_KEY_HERE" >> ~/.ssh/authorized_keys

# Step 5: Set correct permissions
chmod 600 ~/.ssh/authorized_keys
```

#### Method 3: Cloud provider dashboard

On AWS, DigitalOcean, Hetzner or Vultr, add your public key in the provider's dashboard before you create the server. It is the cleanest option for new servers.

**With CtrlOps SSH Setup Wizard:** the wizard shows all three methods with pre-filled commands and a Copy Key button, so there is no hunting for the key file and no typos in a long key string. The [CtrlOps first connection guide](https://ctrlops.io/docs/getting-started/first-connection) walks through it.

The full server add and key setup flow from zero:

Video: https://www.youtube.com/watch?v=KNiBVD3zh9I

> **Reality check:** The most common failure after key setup is wrong file permissions (Practice 10), not a bad key. If octal values never stick in your memory, our free [chmod calculator](https://ctrlops.io/tools/chmod-calculator) translates them both ways.

---

### Practice 8: Manage SSH Access Per User, Not Per Team

Every person who needs SSH access to a server should have their own key pair, with their public key in `authorized_keys`. No sharing private keys between teammates. This is the rule most small teams break, and the one that hurts most when someone leaves.

![Shared team SSH key versus per-user SSH access comparison showing why per-user keys make offboarding and key revocation faster and safer](https://cdn.ctrlops.io/blog/ssh-key-management-best-practices/Shared-Team-Keys-vs-Per-User-SSH-Access.webp)

#### Shared key scenario (dangerous)

The team creates one `team_deploy_key` and everyone uses it. A developer leaves. To be safe, you'd have to regenerate the key and redistribute it to everyone still on the team. Nobody does, so the old key stays valid for months or years.

#### Per-user key scenario (correct)

Each developer has their own key pair. When one leaves, you remove their single entry in 30 seconds, and nobody else is affected.

A clean `authorized_keys` file looks like:

```
ssh-ed25519 AAAA... emily@macbook-pro-2026-11
ssh-ed25519 AAAA... jonas@work-laptop-2026-09
ssh-ed25519 AAAA... deploy@github-actions-2026-11
```

Removing Jonas's access means deleting one line. In CtrlOps' [SSH Management tab](https://ctrlops.io/docs/modules/ssh-management), each key is its own row with its identity and the system user it can log in as, and Add User creates a person's Linux account, sets its role and authorizes their key in one form.

> Per-user keys are your offboarding process: revoking one key takes 30 seconds, while replacing a shared key because one person left interrupts your entire team.

---

### Practice 9: Revoke Access Immediately When Someone Leaves

Revocation is the step that usually happens late, and until it does, a departed person's key works on every server you gave them. It doesn't take bad intent: their laptop can be stolen or their machine compromised. According to [DTEX Systems' 2023 Insider Risk Investigations Report](https://www.dtexsystems.com/blog/2023-insider-risk-investigations-report-the-rise-of-employee-attrition-and-data-exfiltration/), 12% of employees take sensitive IP with them when they leave an organization.

![SSH key revocation workflow for removing a departing developer's key from authorized_keys across every server the same day](https://cdn.ctrlops.io/blog/ssh-key-management-best-practices/SSH-Key-Revocation-Workflow.webp)

#### The manual CLI revocation process

```bash
# SSH into each affected server
ssh username@server-ip

# Open authorized_keys
nano ~/.ssh/authorized_keys

# Find and delete the line with their key comment
# Save and close

# Repeat for every server they had access to
```

For 8 servers, that is 8 SSH sessions and 8 manual file edits: 20 to 30 minutes that often slip to "I'll do it tomorrow."

#### With CtrlOps SSH Management

1. Connect to the server and open the [SSH Management tab](https://ctrlops.io/docs/modules/ssh-management)
2. Find the departing developer's key by its comment
3. Click the red trash icon on that row and choose **Revoke this key**
4. Click **Revoke key** to confirm

The key leaves `authorized_keys` at once, and that person can't connect with it again. Each server takes under 30 seconds, or use **Remove from all servers** in the [Access](https://ctrlops.io/features/access-management) view to take one person's key off every server at once.

> **Reality check:** "We have former devs whose SSH keys are still on production" is what many startup CTOs admit when asked. If your offboarding checklist doesn't say "revoke SSH access the same day," add it today.

**Revoke SSH access before the exit interview ends**

CtrlOps SSH Management shows every authorized key on each server, and you revoke a key from its row. 14-day free trial, no credit card required.

---

### Practice 10: Set Correct File Permissions Every Time

If your key files or `.ssh` directory are too open, OpenSSH rejects the key, and the error never mentions permissions.

**Required permissions:**

```bash
# Your .ssh directory
chmod 700 ~/.ssh

# Your private key
chmod 600 ~/.ssh/id_ed25519

# Your public key
chmod 644 ~/.ssh/id_ed25519.pub

# The authorized_keys file on the server
chmod 600 ~/.ssh/authorized_keys

# The .ssh directory on the server
chmod 700 ~/.ssh
```

The [Chmod Calculator](https://ctrlops.io/tools/chmod-calculator) converts between symbolic and numeric notation if the numbers are new to you.

**Quick permissions audit:**

```bash
ls -la ~/.ssh
```

Anything showing `rw-rw-rw-` (666) or `rwxrwxrwx` (777) will cause auth failures. OpenSSH refuses such keys on purpose: a world-readable private key can be copied by any user on that machine.

**With CtrlOps:** in the [File Manager](https://ctrlops.io/features/file-manager), right-click the server's `.ssh` folder and click **Permissions**. Choose **Owner only** and turn on **Apply recursively to everything inside**: the folder gets 700 and every file in it, `authorized_keys` included, gets 600, the same modes as the commands above. For a single file, type the number (644 for a public key) or tick Read, Write and Execute for owner, group and every other account on the Advanced tab. The dialog shows the owner and the `rwx` string as you change the mode, warns in red before anything becomes world-writable, and won't apply a mode that locks the owner out.

![The CtrlOps Permissions dialog on the Advanced tab for a file owned by root:root, showing mode 644 and rw-r--r--, with Read and Write ticked for owner and only Read ticked for group and every other account](https://cdn.ctrlops.io/docs/set-permission.webp)

When a teammate needs one folder, don't loosen its mode for everyone: **Team access** in the same menu gives that one person Read or Read / Write on that item only. Both need a root or sudo login and aren't on the Free plan.

**On Windows:** If `ssh-add` says it can't connect to the agent, run these commands in PowerShell as Administrator:

```powershell
Set-Service -Name ssh-agent -StartupType Automatic
Start-Service ssh-agent
ssh-add $env:USERPROFILE\.ssh\id_ed25519
```

Still choosing an SSH client for Windows? Our [comparison of SSH clients for Windows](https://ctrlops.io/blog/best-ssh-clients-windows) covers the options.

> Wrong permissions on `authorized_keys` are the top cause of "I added the key and it still fails." Run `chmod 600` and `chmod 700` after every manual key addition, or apply Owner only from the CtrlOps Permissions dialog ([steps with screenshots](https://ctrlops.io/docs/modules/file-manager#set-file-permissions)).

For the same discipline host-wide (world-writable files, set-id binaries, the modes on `/etc/shadow`), see the [file system security audit checklist](https://ctrlops.io/security-checklist/vps/filesystem).

---

### Practice 11: Audit Your SSH Keys Every 90 Days

Every 90 days, check which keys exist on each server and why. Most developers add keys when onboarding and never look again, so old keys from past contractors, retired CI systems and replaced laptops stay valid for years.

![SSH key audit workflow for reviewing authorized_keys on every server and removing unknown or stale keys every 90 days](https://cdn.ctrlops.io/blog/ssh-key-management-best-practices/SSH-Key-Audit-Workflow.webp)

#### Manual SSH key audit on your local machine

```bash
# List all key files
ls -la ~/.ssh/*.pub

# Check what is loaded in the SSH agent
ssh-add -l

# Check key fingerprints
ssh-keygen -lf ~/.ssh/id_ed25519.pub
```

#### Manual SSH key audit on a server

```bash
# SSH in and view all authorized keys
cat ~/.ssh/authorized_keys

# Count entries
wc -l ~/.ssh/authorized_keys
```

For each entry, ask: whose key is this, are they still on the project, and does the key still need this access? The free [authorized_keys Analyzer](https://ctrlops.io/tools/authorized-keys-analyzer) lists every key with its fingerprint and options and flags the ones nobody can account for.

**In CtrlOps:** the SSH Management tab shows [a visual registry](https://ctrlops.io/features/ssh-management) of each server's keys with counters by type, and its [Infra Details](https://ctrlops.io/features/infra-monitoring) tab shows CPU, RAM and disk on the same visit. The [Access view](https://ctrlops.io/features/access-management) lists each person and the servers their key works on, so a key that should be gone stands out.

> Audit every 90 days and after any team change. A manual audit takes about 15 minutes per server.

---

### Practice 12: Use AI to Diagnose SSH Key Errors

`Permission denied (publickey)` doesn't say whether the key, the permissions, `authorized_keys` or the daemon config is wrong, so people end up trying old Stack Overflow answers one by one.

#### With CtrlOps AI Terminal

Open the [AI Terminal](https://ctrlops.io/docs/modules/ai-terminal) tab on your connected server and type exactly what is happening:

> "I'm getting Permission denied (publickey) when connecting. I've added my Ed25519 public key to authorized_keys but it's still failing."

The AI suggests diagnostic commands for that server, which find the cause: wrong permissions on `authorized_keys`, `PubkeyAuthentication no` in `/etc/ssh/sshd_config`, or a key pasted across two lines. Each command waits for Run or Cancel; with Auto-Run on, read-only commands run by themselves, while `sudo` and everything else still ask. [Web Search](https://ctrlops.io/docs/modules/ai-terminal/web-search) lets it check current docs through Tavily, Brave or DuckDuckGo.

To connect an AI, sign in with ChatGPT, use a free OpenRouter model with no API key, add your own OpenAI, Anthropic, Google or OpenAI-compatible key, or run a local model such as Ollama. Requests go straight from your computer to the provider, never through CtrlOps. More in the [AI in DevOps guide](https://ctrlops.io/blog/ai-in-devops).

Video: https://www.youtube.com/watch?v=3Wxoe9Hema0

> Describe the error in plain words and get diagnostic commands for your actual server. You see every command before it runs.

---

### Practice 13: Consider FIDO2 Hardware Keys for Production Access

Standard SSH keys live on disk. With a FIDO2 hardware key, the private key never leaves the physical device.

![Standard on-disk SSH keys versus FIDO2 hardware-backed ed25519-sk keys where the private key never leaves the YubiKey](https://cdn.ctrlops.io/blog/ssh-key-management-best-practices/Standard-SSH-Keys-vs-FIDO2-Hardware-Keys.webp)

An `ed25519-sk` key (`-sk` means security key) is created and stored inside a FIDO2 authenticator such as a YubiKey; your machine holds only a key handle that is useless without it. To log in, you touch the key and the YubiKey signs the server's challenge.

**Setup (requires OpenSSH 8.2+ and a FIDO2-compatible hardware key):**

```bash
# Generate a hardware-backed SSH key
ssh-keygen -t ed25519-sk -O resident -C "yubikey-prod-2026"

# You'll be prompted to touch your YubiKey during generation
# The .pub file goes to the server as normal; the private key stays on the hardware

# Copy the public key to your server
ssh-copy-id -i ~/.ssh/id_ed25519_sk.pub username@server-ip
```

The `-O resident` flag stores the key handle on the YubiKey itself, so you can load the same key on another machine with `ssh-add -K`.

#### When to use FIDO2 keys

- Any production server where a stolen laptop would otherwise mean immediate access
- Shared workstations or CI runners where multiple people have physical access
- Any environment where "physical presence required" is a meaningful security constraint

Passphrase-protected Ed25519 keys cover most small teams; for critical production servers, hardware keys are worth the cost. [Yubico's OpenSSH integration guide](https://developers.yubico.com/SSH/Securing_SSH_with_FIDO2.html) walks through the setup.

> With a FIDO2 key, a stolen laptop is not a server breach. A login needs only a touch, not a PIN, unless you add `-O verify-required`.

---

### Practice 14: Know When SSH Certificates Replace Key Management

Beyond roughly 15 to 20 people, `authorized_keys` files become their own problem. With SSH certificates, servers trust any certificate signed by a central Certificate Authority (CA), and each developer gets a short-lived certificate, valid from a few minutes to a working day, that expires by itself: no standing access, no per-server key files, no revocation step.

For a solo developer or a team of 5, per-user keys with manual revocation (Practices 8 and 9) are enough; for a 30-person org with 80 servers, certificates are the right answer. If you keep forgetting to revoke keys, or auditing `authorized_keys` feels unmanageable, look at an SSH CA. [HashiCorp Vault's SSH secrets engine](https://developer.hashicorp.com/vault/docs/secrets/ssh/signed-ssh-certificates) can act as that CA and sign short-lived certificates. AWS Systems Manager Session Manager takes another route: it replaces SSH keys with IAM-controlled sessions, a trade-off covered in our [web-based vs. local SSH clients](https://ctrlops.io/blog/web-based-vs-local-ssh-client) comparison.

> Under about 20 people, per-user keys with a solid revocation process cover you. Beyond that, evaluate SSH certificates.

## Tools That Help with SSH Key Management

Three kinds of tools cover the 14 practices: OpenSSH itself, free browser tools for one-off jobs, and a desktop app when you manage keys on several servers. Start with OpenSSH, which is free and already installed, and add a tool only where it saves steps. Here is what each one covers, CtrlOps included, with its limits.

### OpenSSH built-ins

| Command | What it does in this guide |
|---|---|
| `ssh-keygen` | Creates keys (Practice 1), changes a passphrase with `-p` (Practice 3) and prints fingerprints with `-lf` (Practices 4 and 11) |
| `ssh-copy-id` | Adds a public key to a server (Practices 4 and 7) |
| `ssh-add` | Loads keys into the agent, and unloads them with `-d` (Practices 2 and 3) |
| `sshd -t` | Tests `sshd_config` before a restart (Practice 1) |
| `expiry-time` | Retires a key in `authorized_keys` on a set date (Practice 4) |

### Free browser tools

- [SSH key generator](https://ctrlops.io/tools/ssh-key-generator): Ed25519 or RSA key pairs, made in your browser
- [SSH config generator](https://ctrlops.io/tools/ssh-config-generator): `~/.ssh/config` blocks for multi-client setups
- [authorized_keys analyzer](https://ctrlops.io/tools/authorized-keys-analyzer): a fingerprint and a grade for every key on a server
- [sshd_config analyzer](https://ctrlops.io/tools/sshd-config-analyzer): an A to F review of a server's SSH settings
- [chmod calculator](https://ctrlops.io/tools/chmod-calculator): permission numbers, both ways

### CtrlOps

CtrlOps is a desktop app for macOS (Apple Silicon and Intel), Windows and Linux. It connects to any Linux server with SSH enabled (AWS, DigitalOcean, Hetzner, Vultr, bare metal), with no agent on the server. For SSH keys it adds:

- **[SSH Setup Wizard](https://ctrlops.io/docs/getting-started/first-connection):** generates an Ed25519 key and shows three ways to put it on a server.
- **[SSH Management tab](https://ctrlops.io/features/ssh-management):** every authorized key on a server; Add User creates the account, sets its role and authorizes the key in one form.
- **[Access](https://ctrlops.io/features/access-management):** each person and the servers their key works on, with Rotate SSH Key and Remove from all servers.
- **[AI Terminal](https://ctrlops.io/features/ai-terminal):** diagnoses SSH errors and asks before each command, with [Web Search](https://ctrlops.io/docs/modules/ai-terminal/web-search) and a [Script Directory](https://ctrlops.io/features/script-directory) for reusable hardening scripts.
- **[Security Audit](https://ctrlops.io/features/security-audit):** checks root login, password authentication and `authorized_keys` permissions, with a hardening score, a PDF report and AI-written fixes you approve.
- **[File Manager](https://ctrlops.io/features/file-manager)** and **[Backups](https://ctrlops.io/features/backup):** set `.ssh` to 700 and its files to 600 with the Permissions dialog, share one folder with a teammate through Team access, edit `sshd_config` without an SFTP app, and back up server folders to S3-compatible storage.
- **[Local-first security model](https://ctrlops.io/docs/core/ssh-security):** key files stay where they are and nothing syncs to a CtrlOps cloud.

| What you need | CtrlOps feature | Time with CtrlOps | Time manually |
|---|---|---|---|
| Generate Ed25519 key | SSH Setup Wizard | Under 2 minutes | 5 min + docs lookup |
| Copy key to server | Wizard, one-click copy | Under 2 minutes | 10 min including errors |
| Rotate a person's key | Access, Rotate SSH Key | One paste for all their servers | 5 commands per server |
| Revoke a departing dev's key | SSH Management tab, trash icon | 30 seconds per server | 5 min per server |
| Audit all keys on a server | SSH Management tab, visual registry | 2 minutes | 10 min per server |
| Diagnose SSH auth errors | AI Terminal, Run or Cancel per command | Under 5 minutes | 30 to 60 min on Stack Overflow |
| Fix permissions or config files | File Manager, Permissions and editor | Under 2 minutes | 10 min via terminal |

Plain-text notes are the other common problem. Softnoesis kept access for fifteen to twenty servers in a notepad file across eight-plus client projects before it moved. [None of those credentials sit in a text file now](https://ctrlops.io/case-studies/softnoesis).

Comparing desktop SSH clients on a Mac? The guide to the [best SSH clients for Mac in 2026](https://ctrlops.io/blog/best-ssh-client-mac-2026) covers your options in detail.

### CtrlOps pricing

- **Free:** up to 2 servers, with no end date. The SSH key wizard is included; SSH Management shows 2 users per server.
- **Personal:** $9 a month or $90 a year (2 months free), with unlimited servers and a 14-day free trial, no credit card.
- **Lifetime:** $349 once for one seat, with unlimited servers, updates for life and a 14-day refund.
- **Team:** $39 a month, or $849 once, for 5 seats.

See [CtrlOps pricing](https://ctrlops.io/pricing).

> **What CtrlOps doesn't do**
>
CtrlOps has no shared team vault (each person's server list stays on their own computer; move it with an encrypted export), no SSH certificate authority (use HashiCorp Vault for that), no key rotation reminders (keep the dates in a calendar) and no mobile app. It is a desktop app for macOS, Windows and Linux, and its server tools are built for Linux servers. On the Free plan, SSH Management shows 2 users per server, and Add User, Access details, Rotate SSH Key and the File Manager's Permissions and Team access are locked; the 14-day trial unlocks them.

**SSH key management without the CLI overhead**

SSH Setup Wizard, a key registry on every server, Rotate SSH Key and revoke from the key's row. 14-day free trial, no credit card required. Or pay once: $349 Lifetime, updates for life.

---

## SSH Key Management Audit Checklist

Run this checklist every 90 days and after every team or project change. It has 8 checks for your own computer, 7 for each server and 5 events that can't wait for the next audit. Most checks only read files, so a full pass takes about 15 minutes per server.

### On your local machine

- List all key pairs: `ls -la ~/.ssh/*.pub`
- Check agent contents: `ssh-add -l`
- Verify every key has a comment that follows your naming pattern
- Confirm `chmod 700 ~/.ssh` and `chmod 600` on all private keys
- Confirm no private keys are in any cloud-synced folder
- Confirm a passphrase on all non-automation keys
- Rotate automation keys older than 90 days (Practice 4)
- Delete or archive keys for projects that ended more than 90 days ago

### On each server

- View all authorized keys: `cat ~/.ssh/authorized_keys`
- Count entries: `wc -l ~/.ssh/authorized_keys`
- Confirm you can identify every entry's owner
- Remove any key without a clear owner
- Verify `chmod 600 ~/.ssh/authorized_keys`
- Verify `chmod 700 ~/.ssh`
- Check `PubkeyAuthentication yes` in `/etc/ssh/sshd_config`

### After team or project events: do these immediately, not later

- Developer leaves: revoke their key from all servers the same day
- Laptop stolen or lost: revoke all keys associated with that device immediately
- Key may have leaked: rotate it at once (Practice 4)
- Project ends: remove your key from the client's servers before the final invoice
- Contractor engagement ends: revoke access before or alongside the final payment

**Find the keys nobody can account for**

Paste a server's authorized_keys file and the free analyzer grades every key, shows its SHA256 fingerprint, and flags keys with no comment, weak keys and duplicates. It runs in your browser.

---

## Conclusion

SSH key management best practices are a routine, not a one-time setup: the right key type, private keys kept local, passphrases, per-user access, rotation on a schedule and same-day revocation. Most of the 14 practices take under 10 minutes the first time, and the audit takes about 15 minutes per server every 90 days.

Start with the three highest-impact changes: Ed25519 keys, passphrases on all personal keys, and one key per person with a real revocation process. Then a stolen laptop or a departed developer no longer means a security incident. To revoke keys in a few clicks instead of an SSH session per server, CtrlOps' [SSH Management module](https://ctrlops.io/docs/modules/ssh-management) costs $9 a month or $349 once, with a 14-day free trial.

---

## FAQ

**What is the best SSH key type to use in 2026?**

Ed25519 is the best SSH key type in 2026 for almost every use: short keys, a security level similar to RSA 3072, and a design that resists timing attacks. Use RSA 4096 only for a legacy system that can't accept Ed25519, which is rare since OpenSSH added it in version 6.5 (2014).

**How do I manage SSH keys for multiple clients as a freelancer?**

Create one Ed25519 key pair per client, such as `client_acme_ed25519`, and map it to that client's servers with `IdentityFile` in `~/.ssh/config`. A compromised key then affects one client, not your whole portfolio, and when a project ends you remove just that key from the client's servers.

**How do I remove a passphrase from an SSH key?**

Run `ssh-keygen -p -f ~/.ssh/your_key_name` and press Enter at the new passphrase prompt. Do this only for a dedicated automation key; for daily use, load your key with `ssh-add` so you type the passphrase once per session.

**How do I delete an SSH key (from a server or my local machine)?**

**From a server**, delete the key's line from `~/.ssh/authorized_keys` (in CtrlOps, click the red trash icon on its row and choose Revoke this key). The server refuses the key from then on, with no restart.

**From your local machine**, unload it with `ssh-add -d ~/.ssh/your_key_name` and delete both key files. `shred -u` overwrites a file before deleting it, but the [GNU shred manual](https://www.gnu.org/software/coreutils/manual/html_node/shred-invocation.html) warns that SSDs and journaling file systems can keep old copies, so full-disk encryption (FileVault, BitLocker or LUKS) is what really protects a deleted key.

**What are the correct file permissions for SSH keys?**

Private key `chmod 600`, `~/.ssh/` directory `chmod 700`, and `authorized_keys` on the server `chmod 600`. If they are wrong, OpenSSH rejects the key with "Permission denied (publickey)" even though the key itself is fine.

**How often should I rotate SSH keys?**

Rotate CI/CD and other automation keys every 90 days, personal keys once a year, and any key at once when someone leaves, a laptop goes missing or a key may have leaked. Always add the new key and test it before you remove the old one; Practice 4 shows the five commands.

**Is it safe to store SSH private keys in a password manager?**

A password manager such as 1Password keeps SSH keys in an end-to-end encrypted vault that syncs to your devices, which is far safer than a plain file in Dropbox or iCloud. If a contract says keys may exist on one device only, use local key files with an encrypted backup instead.

**When should I not use SSH key authentication?**

Only when you can't set up keys yet, for example on first access to a new server. Once key login works, set `PasswordAuthentication no` in `/etc/ssh/sshd_config` to stop password brute-force attacks.

**What happens if my laptop is stolen and my SSH keys are on it?**

Without a passphrase, every server that trusts those keys is at risk right away, so remove the laptop's public keys from `authorized_keys` on every affected server from another machine. With per-machine keys, only that laptop's servers are exposed; with one key for everything, you revoke access everywhere.

**How is CtrlOps different from Termius for SSH key management?**

Termius keeps data in a local vault on its free Starter plan; paid plans add a personal cloud vault that syncs across desktop and mobile with end-to-end encryption. CtrlOps has no cloud sync: key files stay where they are and server details are encrypted on your computer. Pick Termius to have your servers on your phone too, or CtrlOps for no copy outside your devices plus SSH Management, an approval-gated AI Terminal and backups. CtrlOps is free for up to 2 servers, then $9 a month or $349 once ([CtrlOps vs Termius](https://ctrlops.io/compare/ctrlops-vs-termius)).

**What is ssh-copy-id and when should I use it?**

`ssh-copy-id -i ~/.ssh/id_ed25519.pub username@server-ip` adds your public key to a server's `authorized_keys`, creating the directory and setting permissions in one step. Use it when you can already log in with a password or another key; otherwise append the key by hand and set `chmod 700 ~/.ssh` and `chmod 600 ~/.ssh/authorized_keys`.

**What are common SSH key management mistakes?**

One key for everything, keys without a passphrase, shared team keys, keys left behind after people leave, private keys in cloud folders or Git, wrong permissions, and keys with no comment. Each one maps to a practice in this guide, and the audit checklist catches most of them in one pass.
