Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

authorized_keys

Direct answer

~/.ssh/authorized_keys lists the public keys allowed to log in as that user, one per line, optionally with options such as from=, command= and restrict.

When to use this

Use it to grant or revoke key access, or when a key is refused.

First 30 seconds

1. ls -ld ~ ~/.ssh; ls -l ~/.ssh/authorized_keys — owner and 700/600?

2. Key line intact (one line)?

3. Options (from=, command=) blocking it?

4. Server log for refusals.

5. Test login.

Operational verification

key added on one line → strict permissions → sshd reads the file → key and options matched

Evidence · next step

For SSH → authorized_keys, continue with the first unproven Topic check: Resolve effective AuthorizedKeysFile/AuthorizedKeysCommand for the target user. If that boundary is healthy, advance to the adjacent check: Match by fingerprint rather than visually comparing long key blobs. 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 grant or revoke key access, or when a key is refused.
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.

5 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

target account → effective authorized-key source → path ownership/modes → entry fingerprint/options → signature acceptance → forced/restricted channel policy → workload

Healthy evidence: sshd resolves the intended authorization source, the exact fingerprint is present with understood restrictions, path permissions satisfy policy and the requested key-based operation works.

Step 2 Verification and output interpretation Verify boundary

Existing fast checks for this Topic. - Resolve effective AuthorizedKeysFile/AuthorizedKeysCommand for the target user.

  • Match by fingerprint rather than visually comparing long key blobs.
  • Inspect entry options plus ownership/modes of the file and path components relevant to StrictModes.
  • Authenticate with the exact key and verify the requested action is permitted by entry/server policy.

Verification chain. target account → effective authorized-key source → path ownership/modes → entry fingerprint/options → signature acceptance → forced/restricted channel policy → workload

Step 3 Commands Verify boundary
cat ~/.ssh/authorized_keys
chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: key is in the wrong user/home/file, options force another command, path permissions cause sshd rejection or a matching key is assumed to grant capabilities that are explicitly disabled.

Step 5 Common mistakes Narrow the fault
  • Wrong permissions, so sshd ignores the file.
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

One key per line, no line breaks. Remove a key to revoke access. Use from="<net>" to limit where a key may be used. Ownership and permissions must be strict or sshd ignores the file.

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

Verify the target account, actual AuthorizedKeysFile/command source and exact key fingerprint. Parse key options before the key material, confirm StrictModes-relevant ownership/path permissions, then distinguish key authorization from subsequent shell/filesystem/privilege access.

ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

An authorized_keys match shows account-specific key authorization subject to entry/server policy, but it does not show filesystem access, sudo privilege or downstream application rights.

authorized_keys owns per-account SSH key authorization entries.

In depth

authorized_keys: format and per-key restrictions

Each line in ~/.ssh/authorized_keys allows one public key to log in as that user, optionally with restrictions. The sshd(8) manual page defines the format:

  • Each line holds optional options, the key type, the base64 key and a comment.
  • Blank lines and lines starting with # are ignored.
  • RSA keys must be at least 1024 bits.
  • The file is used only if it and its parent directories aren't writable by others (StrictModes).

Key options (manual)

OptionEffect
from="10.99.0.0/24,*.example.net"Only accept the key from matching addresses or names
command="..."Always run this command; the requested one is in SSH_ORIGINAL_COMMAND
restrictDisable port, agent and X11 forwarding, PTY allocation and ~/.ssh/rc
pty, port-forwardingRe-enable single features after restrict
no-port-forwardingDisable TCP forwarding only
permitopen="host:port"Limit -L forwarding to these destinations
permitlisten="[host:]port"Limit -R forwarding to these listeners
expiry-time="YYYYMMDD"Reject the key after this date

Typical restricted keys

PurposeLine pattern
Backup jobrestrict,from="10.99.0.25",command="/usr/local/bin/backup-receive" ssh-ed25519 AAAA... backup@bkp1
Monitoring checkrestrict,command="/usr/lib/nagios/plugins/check_disk -w 20% -c 10%" ssh-ed25519 AAAA... mon@mon1
Tunnel to one databaserestrict,port-forwarding,permitopen="10.30.0.40:5432" ssh-ed25519 AAAA... app@app1
Contractor, time-limitedexpiry-time="20261231",from="203.0.113.0/24" ssh-ed25519 AAAA... contractor
srv1$ stat -c '%a %U %n' ~admin ~admin/.ssh ~admin/.ssh/authorized_keys
755 admin /home/admin
700 admin /home/admin/.ssh
600 admin /home/admin/.ssh/authorized_keys
srv1$ ssh-keygen -l -f ~admin/.ssh/authorized_keys
256 SHA256:Qb... admin@laptop-2026 (ED25519)
256 SHA256:7k... backup@bkp1 (ED25519)
srv1$ sudo journalctl -u ssh | grep "Accepted publickey" | tail -3
Accepted publickey for admin from 10.110.0.64 port 51234 ssh2: ED25519 SHA256:Qb...

Auditing keys

ssh-keygen -l -f authorized_keys lists the fingerprint of every key in the file. With LogLevel VERBOSE, the server logs the fingerprint used for each login. Matching the two shows which keys are actually used, and which ones can be removed.

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

authorized_keys is part of SSH → authorized_keys. authorized_keys is an account-scoped SSH authorization source mapping accepted public keys to optional restrictions such as forced commands, source-address limits, environment constraints and forwarding permissions; file ownership/mode and lookup method affect whether sshd will trust it.

Public-key authentication additionally depends on key type/signature support, authorized_keys lookup and file/account policy.

Topic-specific state model. authorized_keys is an account-scoped SSH authorization source mapping accepted public keys to optional restrictions such as forced commands, source-address limits, environment constraints and forwarding permissions; file ownership/mode and lookup method affect whether sshd will trust it.

Interpretation rule. - Key text present ≠ sshd reads that file for this account.

  • Matching public key ≠ entry has no restrictive options.
  • Correct file mode alone ≠ parent directory ownership/path safety is valid.
  • Key authorization ≠ unrestricted command, PTY, agent, X11 or port-forwarding rights.

Quick reference

~/.ssh/authorized_keys lists allowed public keys, optionally with restrictions:

ssh-ed25519 AAAAC3… alice@laptop
from="10.0.0.0/8",no-agent-forwarding,no-port-forwarding,command="/usr/local/bin/backup-receive" ssh-ed25519 AAAAC3… backup@srv02
restrict,command="rrsync -ro /srv/data" ssh-ed25519 AAAAC3… rsync-pull

Permissions: home not group/world-writable, ~/.ssh 700, authorized_keys 600, owned by the user — otherwise StrictModes rejects it. Central alternatives: AuthorizedKeysCommand (LDAP/SSSD), AuthorizedKeysFile in a root-owned location.

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. An authorized_keys match shows account-specific key authorization subject to entry/server policy, but it does not show filesystem access, sudo privilege or downstream application rights.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Keep host keys separate from user keys. authorized_keys permissions/ownership, AuthorizedKeysFile/Command, PAM, Allow/Deny rules and SELinux/AppArmor can all affect authorization.

Distribution/platform context. authorized_keys owns per-account SSH key authorization entries. Public Key Authentication owns protocol authentication; Users/Permissions owns filesystem ownership/modes and account identity.

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 → authorized_keys. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://www.openssh.com/manual.html · confidence 94%
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
authorized_keysssh authorized keysauthorizedkeysfilessh key restrictions
Embedded reference data

Quick lookup tables

authorized_keys operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for authorized_keys.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateauthorized_keys is an account-scoped SSH authorization source mapping accepted public keys to optional restrictions such as forced commands, source-address limits, environment constraints and forwarding permissions; file ownership/mode and lookup method affect whether sshd will trust it.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 chaintarget account → effective authorized-key source → path ownership/modes → entry fingerprint/options → signature acceptance → forced/restricted channel policy → workloadTrace requested/configured state through effective state to the observed workload result.
Failure boundaryAn authorized_keys match proves account-specific key authorization subject to entry/server policy; it does not prove filesystem access, sudo privilege or downstream application rights.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated Linux SSH evidence can establish this proof path: target account → effective authorized-key source → path ownership/modes → entry fingerprint/options → signature acceptance → forced/restricted channel policy → 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. An authorized_keys match proves account-specific key authorization subject to entry/server policy; it does not prove filesystem access, sudo privilege or downstream application rights.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.

authorized_keys · operational reference

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

Reference boundaryauthorized_keys
Topic pathSSH → authorized_keys
Runtime stateauthorized_keys is an account-scoped SSH authorization source mapping accepted public keys to optional restrictions such as forced commands, source-address limits, environment constraints and forwarding permissions; file ownership/mode and lookup method affect whether sshd will trust it.
Fast checks- Resolve effective AuthorizedKeysFile/AuthorizedKeysCommand for the target user. - Match by fingerprint rather than visually comparing long key blobs. - Inspect entry options plus ownership/modes of the file and path components relevant to StrictModes. - Authenticate with the exact key and verify the requested action is permitted by entry/server policy.
Verification chaintarget account → effective authorized-key source → path ownership/modes → entry fingerprint/options → signature acceptance → forced/restricted channel policy → 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 boundaryAn authorized_keys match proves account-specific key authorization subject to entry/server policy; it does not prove filesystem access, sudo privilege or downstream application rights. 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.
Confirmation

Confirm action

Continue?