SSH Key Input

SSH Key Input is a copy-paste React component that stops private ssh key pasted where a public key belongs before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/ssh-key-input
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsPrivate SSH key pasted where a public key belongs

Was this component page useful?

How do I install SSH Key Input?

pnpm dlx shadcn@latest add @bollard/ssh-key-input

The files land in your project. They're yours to edit.

How do I use SSH Key Input in React?

ssh-key-input-usage.tsx
import { decodeBase64, encodeBase64, SshKeyInput } from "@/components/ui/ssh-key-input"

<SshKeyInput value={value} onValueChange={setValue} existing={[{ key: LAPTOP, label: "MacBook (added 3 Sep)" }]} />

What input mistakes does SSH Key Input catch?

  • A private key pasted instead of a public one, with rotate advice and the public half extracted when possible
  • DSA keys and RSA keys under minRsaBits (default 2048; 3072 recommended)
  • Keys wrapped across lines or cut off
  • Missing or mismatched type prefix
  • RFC 4716 (SSH2) export format, converted
  • A key already on the account

What props does SSH Key Input accept?

SshKeyInput props
PropTypeDefault
value

Controlled text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the new text on every edit or fix.

(value: string) => void—
onAnalysisChange

Called whenever the reading changes, so a form can enable its Add button only for a clean key.

(analysis: SshKeyAnalysis) => void—
existing

Keys already on the account (line or "SHA256:…" fingerprint, with a label). A repeat is flagged by name.

ExistingSshKey[]NONE
minRsaBits

RSA keys below this are rejected. Default 2048.

number2048
recommendedRsaBits

RSA keys below this get a softer warning. Default 3072, GitHub's minimum for new keys.

number3072
label

Visible label; shorthand for `messages.label`.

string—
messages

Every visible string. `{detail}`, `{bits}`, `{min}`, `{recommended}`, `{name}`, `{count}` are filled in.

Partial<SshKeyInputMessages>—

* required. Also accepts the native props of <textarea> (className, aria-*, data-*…), passed through to it.

How is SSH Key Input accessible?

  • Visible <label>; aria-invalid on blocking issues; hint and report via aria-describedby
  • Private-key warning uses role=alert; summary is role=status
  • After a fix, focus moves to the next fix or back to the field

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Re-validate the key server-side, reject private keys and weak types, and never log submitted key material.

  • Checks key format and size, not who owns the key
  • A pasted private key has already been exposed to this page; advise rotation regardless
  • Certificate and hardware-key (sk-) variants may be reported generically

What expensive mistakes does SSH Key Input stop?

Private SSH key pasted where a public key belongs

Also known as

ssh key · public key · id_ed25519.pub · authorized_keys · deploy key · github ssh · fingerprint · ssh-keygen

What dependencies does SSH Key Input require?

SSH Key Input facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameSSH Key Input
Registry identifier@bollard/ssh-key-input
Install commandnpx shadcn@latest add @bollard/ssh-key-input
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about SSH Key Input

What form validation mistake does SSH Key Input catch?

SSH Key Input prevents private SSH key pasted where a public key belongs. Catches a private SSH key pasted where a public key belongs, plus weak, truncated or malformed public keys, before they're saved. Catches: A private key pasted instead of a public one, with rotate advice and the public half extracted when possible, DSA keys and RSA keys under minRsaBits (default 2048; 3072 recommended), Keys wrapped across lines or cut off, Missing or mismatched type prefix, RFC 4716 (SSH2) export format, converted, A key already on the account. Limitation: validate ssh-key-input schemas on backend.

How do I install ssh-key-input with shadcn?

Run `npx shadcn@latest add @bollard/ssh-key-input`. Sources added: registry/default/ssh-key-input/ssh-key-input.tsx, registry/default/ssh-key-input/ssh-key.ts. Package requirements: lucide-react.

What props customize SSH Key Input?

SSH Key Input accepts `value`, `defaultValue`, `onValueChange`, `onAnalysisChange`, `existing`. Configures ssh key, public key, id_ed25519.pub behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of ssh-key-input?

Checks key format and size, not who owns the key. A pasted private key has already been exposed to this page; advise rotation regardless. Certificate and hardware-key (sk-) variants may be reported generically Server requirement: Re-validate the key server-side, reject private keys and weak types, and never log submitted key material.

How does SSH Key Input meet accessibility guidelines?

Visible <label>; aria-invalid on blocking issues; hint and report via aria-describedby. Private-key warning uses role=alert; summary is role=status. After a fix, focus moves to the next fix or back to the field. Minimizes errors: pasted private key instead of public, ssh key invalid format.

Which components pair with SSH Key Input?