Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

Public Key Authentication

Direct answer

Public key authentication logs in with a key pair: the private key stays on the client, the public key is placed in the server user's ~/.ssh/authorized_keys. The server checks a signature made with the private key.

When to use this

Use it to replace password logins, or when a key is not accepted.

First 30 seconds

1. ssh -v — "Offering public key" and "Server accepts key"?

2. Server: key line present in authorized_keys?

3. Permissions: namei -l ~/.ssh/authorized_keys.

4. Server log: "Authentication refused: bad ownership or modes"?

5. PubkeyAuthentication yes in sshd -T.

Operational verification

client offers the public key → server finds it in authorized_keys → client signs a challenge → server verifies → login

Evidence · next step

For SSH → Public Key Authentication, continue with the first unproven Topic check: Identify the exact key fingerprint, agent/file source and target username. If that boundary is healthy, advance to the adjacent check: Confirm the client offers the intended key and the server authorization source contains the matching key/certificate. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it to replace password logins, or when a key is not accepted.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

7 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

private-key source/agent → client identity selection → public-key offer → server authorization lookup → signature verification → key options/account policy → session/channel → workload

Healthy evidence: the intended key fingerprint is selected and accepted under current algorithm/server policy, authorization options are understood and the requested session succeeds.

Step 2 Verification and output interpretation Verify boundary

Existing fast checks for this Topic. - Identify the exact key fingerprint, agent/file source and target username.

  • Confirm the client offers the intended key and the server authorization source contains the matching key/certificate.
  • Verify key algorithm/policy, authorized-key options and ownership/mode constraints.
  • After authentication, verify the requested shell/command/subsystem and any privilege transition.

Verification chain. private-key source/agent → client identity selection → public-key offer → server authorization lookup → signature verification → key options/account policy → session/channel → workload

Step 3 Specialized verification Verify boundary

Use verbose client output to determine which key is offered and whether the server accepts it, then correlate server logs for the same attempt. Confirm target username, home directory, AuthorizedKeysFile resolution, key fingerprint and file permissions. If certificates or external key commands are used, verify that path explicitly. A file containing the public key is not enough; show a new connection succeeds with the expected key while alternative credentials are not accidentally masking the test.

Step 4 Commands Verify boundary
ssh-keygen -t ed25519 -C alice@laptop
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@host
Step 5 Failure modes and next checks Narrow the fault

Suspicious evidence: wrong agent key is offered, deprecated algorithm policy blocks a valid-looking key, authorized-key options restrict the action or accepted authentication is mistaken for unrestricted access.

Step 6 Special cases and limits Narrow the fault

Host keys authenticate the server; user public keys authenticate the client account—do not conflate them. “Permission denied (publickey)” can reflect no matching key, refused algorithm, bad ownership, account restrictions, Match policy or authorization command failure. ssh-agent possession does not mean ssh will offer the desired key. A successful key authentication still does not show the user can execute the intended command or access the target resource.

Step 7 Common mistakes Narrow the fault
  • Private keys without passphrase on shared machines.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

Generate with ssh-keygen -t ed25519, copy with ssh-copy-id. Protect the private key with a passphrase and ssh-agent. Strict permissions are required on the server (~ not group-writable, ~/.ssh 700, authorized_keys 600).

Key checks
  • ssh -v user@host — client-side connection and authentication steps
  • journalctl -u ssh -u sshd -e — server log
  • sshd -T — effective server settings
  • ss -ltnp | grep :22 — sshd listening
ReferenceWhat it is1 section · depth on demand

Core model

Trace identity selection, public-key offer, server authorization lookup and signature acceptance separately. Verify algorithm compatibility and key options/certificates where applicable, then continue through account/session policy rather than stopping at an accepted key.

ReferenceImportant terms & boundaries6 sections · depth on demand

What this shows and what it does not

Accepted public-key authentication shows possession plus server acceptance for one identity/context, but it does not show general authorization, sudo rights, unrestricted forwarding or workload success.

In depth

Public key authentication: generating and managing keys

Public key authentication replaces passwords with a key pair. The private key stays on the client, and the public key is installed on the server. The ssh-keygen(1) manual page covers creating and handling keys:

  • Without arguments, ssh-keygen generates an Ed25519 key.
  • RSA keys default to 3072 bits (minimum 1024). ECDSA supports 256, 384 or 521 bits.
  • The -sk types (ecdsa-sk, ed25519-sk) keep the key on a FIDO hardware token.
  • -C sets the comment, by default user@host. -p changes the passphrase.
  • -l shows a fingerprint, SHA256 by default. -y prints the public key derived from a private key file.

Choosing a key type

TypeWhen
ed25519Default for new keys
ed25519-sk / ecdsa-skA hardware token is required to log in (phishing-resistant)
rsa (3072+)Older systems that don't support Ed25519

Deploying the key

StepCommand
Create, with a passphrasessh-keygen -t ed25519 -C "admin@laptop-2026"
Copy to a serverssh-copy-id -i ~/.ssh/id_ed25519.pub admin@srv1
Load into the agent once per sessionssh-add ~/.ssh/id_ed25519
Check what the agent holdsssh-add -l

SSH certificates

For many servers, managing individual keys doesn't scale. A CA key can sign user keys with -s (the CA key), -I (the identity, which servers log), -n (the allowed principals) and -V (the validity). Servers then trust the CA instead of each key.

admin$ ssh-keygen -t ed25519 -C "admin@laptop-2026" -f ~/.ssh/id_ed25519_work
Generating public/private ed25519 key pair.
Enter passphrase (empty for no passphrase):
admin$ ssh-keygen -l -f ~/.ssh/id_ed25519_work.pub
256 SHA256:Qb... admin@laptop-2026 (ED25519)
admin$ ssh-copy-id -i ~/.ssh/id_ed25519_work.pub admin@srv1
ca$ ssh-keygen -s /secure/user_ca -I admin-2026q4 -n admin -V +8h ~/admin_id_ed25519_work.pub
ca$ ssh-keygen -L -f ~/admin_id_ed25519_work-cert.pub | grep -E "Key ID|Principals|Valid" -A1
srv1$ grep TrustedUserCAKeys /etc/ssh/sshd_config.d/*.conf

Short-lived certificates

An eight-hour certificate, like the one in the example, expires by itself. There are then no stale keys left in authorized_keys when people change roles. That's the main operational advantage over plain keys.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

Public Key Authentication is part of SSH → Public Key Authentication. SSH public-key authentication shows possession of a private key corresponding to a server-authorized public key, subject to server algorithm policy, key options, account policy and filesystem safety checks; it is not equivalent to generic account authorization.

Topic-specific state model. SSH public-key authentication shows possession of a private key corresponding to a server-authorized public key, subject to server algorithm policy, key options, account policy and filesystem safety checks; it is not equivalent to generic account authorization.

Interpretation rule. - Private key file exists ≠ client selected or can use it.

  • Public key present on server ≠ sshd accepted its algorithm/options/ownership context.
  • Key accepted ≠ account/session/command/forwarding policy permits requested action.
  • Passwordless login ≠ key lifecycle, revocation or least privilege is sound.

Specialized mechanics

SSH public-key authentication is a challenge/signature exchange: the client shows possession of a private key while the server checks whether the corresponding public key is authorized for the target account and permitted by policy. The private key never needs to be copied to the server. Key selection can be influenced by ssh-agent, client config and offered-key limits, while server authorization can come from AuthorizedKeysFile or an external command and may include per-key restrictions.

Quick reference

Public key authentication: the client shows possession of the private key; the server checks the public key against authorized_keys.

ssh-keygen -t ed25519 -a 100 -C 'alice@laptop'
ssh-copy-id -i ~/.ssh/id_ed25519.pub alice@web01
ssh-add -l; ssh-add ~/.ssh/id_ed25519
ssh-keygen -lf ~/.ssh/id_ed25519.pub         # fingerprint
ssh-keygen -t ed25519-sk                      # FIDO2 hardware key

Protect private keys with passphrases (agent caches them), use hardware-backed keys for admins, and for fleets consider SSH certificates (TrustedUserCAKeys) to avoid distributing keys to every server.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. Accepted public-key authentication shows possession plus server acceptance for one identity/context, but it does not show general authorization, sudo rights, unrestricted forwarding or workload success.

ReferenceConfiguration & state2 sections · depth on demand

Configuration, persistence and lifecycle

Distribution/platform context. Public Key Authentication owns the SSH authentication mechanism. authorized_keys owns per-account authorization entries, ssh-keygen owns key creation/inspection command semantics and Users/Permissions owns local file/account permissions.

Specialized lifecycle

Protect private keys and configure client identity selection deliberately, especially when many agent keys exist. On the server, keep authorized_keys ownership/mode and parent-directory security consistent with StrictModes expectations, and use key options such as from=, command= or restrict when they express the actual access contract. Rotations should add and verify the new key before removing the old one. Do not disable host-key checking or password policy as a workaround for a user-key problem.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in SSH → Public Key Authentication. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.openssh.com/manual.html · confidence 94%
2026-09-13 · vendor docOpenSSH current

Authoritative Linux project/vendor documentation reviewed for bounded reference claims: public-key authentication flow, authorized keys and server-side acceptance. Documentation-based technical verification only; not lab or production-runtime proof. The schema vendor_doc method is used for authoritative project/vendor documentation; deployment applicability remains separate evidence.

Basis: https://man.openbsd.org/sshd · confidence 93%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
ssh public key authenticationssh keyspasswordless sshssh key auth
Embedded reference data

Quick lookup tables

Public Key Authentication operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Public Key Authentication.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateSSH public-key authentication proves possession of a private key corresponding to a server-authorized public key, subject to server algorithm policy, key options, account policy and filesystem safety checks; it is not equivalent to generic account authorization.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin exact client/server + attempt time → resolve destination/TCP path → inspect effective client config → identify OpenSSH versions → verify KEX + host-key trust → trace offered/accepted authentication → inspect effective sshd policy for user/source → verify session/subsystem/forward → verify remote process/filesystem/service → repeat original workload.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainprivate-key source/agent → client identity selection → public-key offer → server authorization lookup → signature verification → key options/account policy → session/channel → workloadTrace requested/configured state through effective state to the observed workload result.
Failure boundaryAccepted public-key authentication proves possession plus server acceptance for one identity/context; it does not prove general authorization, sudo rights, unrestricted forwarding or workload success.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux SSH evidence can establish this proof path: private-key source/agent → client identity selection → public-key offer → server authorization lookup → signature verification → key options/account policy → session/channel → workloadUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove behavior outside the captured transport, trust, authentication, policy, session, filesystem or workload scope. Accepted public-key authentication proves possession plus server acceptance for one identity/context; it does not prove general authorization, sudo rights, unrestricted forwarding or workload success.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven boundary: correlate client and server evidence for the same attempt, inspect effective client/server configuration and identity/trust/authentication state, then test the exact requested session, transfer or forward before changing additional layers.Continue to the next unresolved boundary while preserving the original test condition.

Public Key Authentication · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundaryPublic Key Authentication
Topic pathSSH → Public Key Authentication
Runtime stateSSH public-key authentication proves possession of a private key corresponding to a server-authorized public key, subject to server algorithm policy, key options, account policy and filesystem safety checks; it is not equivalent to generic account authorization.
Fast checks- Identify the exact key fingerprint, agent/file source and target username. - Confirm the client offers the intended key and the server authorization source contains the matching key/certificate. - Verify key algorithm/policy, authorized-key options and ownership/mode constraints. - After authentication, verify the requested shell/command/subsystem and any privilege transition.
Verification chainprivate-key source/agent → client identity selection → public-key offer → server authorization lookup → signature verification → key options/account policy → session/channel → workload Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundaryAccepted public-key authentication proves possession plus server acceptance for one identity/context; it does not prove general authorization, sudo rights, unrestricted forwarding or workload success. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.

Public Key Authentication · specialized operational reference

Topic-specific Linux mechanics, lifecycle, proof path and failure-boundary lookup.

Operational boundaryTopic-specific reference
Client proofPrivate-key signature; agent/config selects key
Server policyAuthorizedKeysFile/command + sshd policy + file security
IdentityTarget username + key fingerprint
ProofFresh connection succeeds with expected key and restrictions
Confirmation

Confirm action

Continue?