The SSH client should record server.example's host key and detect unexpected changes on later connections.
Use the standard per-user file.
Which file is relevant?
known_hosts records destination host keys on the client and helps detect impersonation or unexpected key changes.
Detailed explanation
~/.ssh/authorized_keysIncorrect. authorized_keys stores user public keys accepted by a server.
~/.ssh/known_hostsCorrect. ~/.ssh/known_hosts records keys for remote hosts.
~/.ssh/id_rsaIncorrect. id_rsa is the user's private key.
/etc/passwdIncorrect. /etc/passwd stores local account records.
Try it yourself
An example you can run in a temporary verification environment.
ssh -G server.example | grep '^userknownhostsfile'Expected result
利用者known_hostsの設定パスKey points
- Host identity
- Client side
- Key-change detection
Notes
- Environment: OpenSSH 9.x
- Use a disposable VM or test account when validating installation and SSH behavior.
- Exact command output can vary slightly by distribution and OpenSSH version.
Foundation review
Identify the scope
Host identity and user authentication are separate trust relationships with different files and owners.
Check the side effect
Confirm an unexpected host-key change through a trusted channel before accepting the new key.