XK0-005 · Question #123
A Linux systems administrator is setting up SSH access with PKI for several using their newly created RSA keys. Which of the following MOST securely achieves this task?
The correct answer is C. Use ssh-copy-id to copy each user's public key file to the respective system. The ssh-copy-id command securely copies a user's public key to a remote server's authorized_keys file, handling permissions and directory creation automatically.
Question
A Linux systems administrator is setting up SSH access with PKI for several using their newly created RSA keys. Which of the following MOST securely achieves this task?
Options
- AUse curl to copy each user's public key file to the respective system
- BUse cp to copy each user's public key file to the respective system
- CUse ssh-copy-id to copy each user's public key file to the respective system
- DUse ssh-copy-id to copy each user's private key file to the respective system
How the community answered
(33 responses)- A9% (3)
- B18% (6)
- C70% (23)
- D3% (1)
Why each option
The `ssh-copy-id` command securely copies a user's public key to a remote server's `authorized_keys` file, handling permissions and directory creation automatically.
Using `curl` to copy a public key is generally not secure for this purpose, as it may not handle permissions correctly and could expose the key during transfer if not used with HTTPS and proper authentication.
Using `cp` directly to copy a public key would require manual secure transfer (e.g., via `scp` or `sftp`) and then manual permission setting on the remote server, which is less secure and more error-prone than `ssh-copy-id`.
The `ssh-copy-id` utility is specifically designed to securely copy a user's public key to the remote server's `~/.ssh/authorized_keys` file. It automatically creates the `.ssh` directory and sets correct permissions, ensuring the private key remains secure and is never exposed or transferred.
Copying a user's *private* key to a remote system is a severe security risk, as private keys should always remain exclusively on the user's local machine and never be shared or stored on public-facing servers.
Concept tested: Secure SSH key deployment using ssh-copy-id
Source: https://man7.org/linux/man-pages/man1/ssh-copy-id.1.html
Topics
Community Discussion
No community discussion yet for this question.