An SSH client compares a previously seen server host key with the key presented now.
Which file stores this comparison data?
~/.ssh/known_hosts stores remote host public keys and helps detect impersonation or unexpected key changes.
Detailed explanation
~/.ssh/authorized_keysCorrect. known_hosts records remote host keys.
~/.ssh/known_hostsIncorrect. authorized_keys is server-side user-key authorization.
~/.ssh/id_ed25519Incorrect. id_ed25519 is the client's private key.
/etc/shadowIncorrect. /etc/shadow stores local authentication data.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s\n' '~/.ssh/known_hosts stores server host keys'Expected result
~/.ssh/known_hosts stores server host keysKey points
- Remote host keys
- known_hosts
- Different from authorized_keys
Notes
- Environment: OpenSSH clientのファイル役割
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Host key
A server identity key used by SSH clients to detect a changed endpoint.
User key
A key pair used to authenticate a user to an SSH server.
Port forwarding
An SSH tunnel that carries traffic between a local, remote, or dynamic endpoint.