Allow Alice's public-key authentication on server.example.
Register the key for Alice's account on the destination host.
Which location is standard?
The destination user's allowed public keys are stored in ~/.ssh/authorized_keys. Never copy the private key there.
Detailed explanation
~alice/.ssh/authorized_keysCorrect. Alice's public key belongs in her remote ~/.ssh/authorized_keys.
Correct. Alice's public key belongs in her remote ~/.ssh/authorized_keys.
~alice/.ssh/known_hostsIncorrect. known_hosts stores client-side host keys.
Incorrect. known_hosts stores client-side host keys.
~alice/.ssh/id_rsaIncorrect. id_rsa is a private key and must remain on the client.
Incorrect. id_rsa is a private key and must remain on the client.
/etc/hostsIncorrect. /etc/hosts maps names to addresses and is unrelated to SSH key authentication.
Incorrect. /etc/hosts maps names to addresses and is unrelated to SSH key authentication.
Try it yourself
An example you can run in a temporary verification environment.
ssh -G server.example | grep '^userknownhostsfile'Expected result
クライアント側known_hosts設定。authorized_keysとは役割が異なるKey points
- Public key
- authorized_keys
- Remote account
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.