On the server, permit trainee to authenticate with a public key using the normal OpenSSH home-directory setup.
Which file should receive the key?
sshd reads a user's ~/.ssh/authorized_keys for permitted public keys. known_hosts stores client-side host keys.
Detailed explanation
~trainee/.ssh/known_hostsIncorrect. known_hosts records remote host keys for the client.
Incorrect. known_hosts records remote host keys for the client.
/etc/ssh/ssh_host_rsa_key.pubIncorrect. This is the server's own host public key.
Incorrect. This is the server's own host public key.
~trainee/.ssh/configIncorrect. config is a client-side connection configuration file.
Incorrect. config is a client-side connection configuration file.
~trainee/.ssh/authorized_keysCorrect. authorized_keys lists public keys allowed for the user.
Correct. authorized_keys lists public keys allowed for the user.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); mkdir -p "$tmp/.ssh"; touch "$tmp/.ssh/authorized_keys"; test -f "$tmp/.ssh/authorized_keys" && printf 'authorized_keys\n'; rm -rf "$tmp"Expected result
authorized_keysKey points
- authorized_keys
- known_hosts is different
- Host key is different
Notes
- Environment: OpenSSHのファイル役割 / 一時ディレクトリ
- 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.