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.
Incorrect. authorized_keys stores user public keys accepted by a server.
~/.ssh/known_hostsCorrect. ~/.ssh/known_hosts records keys for remote hosts.
Correct. ~/.ssh/known_hosts records keys for remote hosts.
~/.ssh/id_rsaIncorrect. id_rsa is the user's private key.
Incorrect. id_rsa is the user's private key.
/etc/passwdIncorrect. /etc/passwd stores local account records.
Incorrect. /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
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.