ssh-copy-id
Networking
Usage
ssh-copy-id -i <key.pub> <user>@<host>Appends your public key to the server's ~/.ssh/authorized_keys so it stops asking for a password; password login has to still be open for that first run, and `-i` takes the `.pub` file, not the private key.
Common flags
| Flag | Meaning |
|---|---|
| -i <key.pub> | Which public key to install. Point it at the .pub file. |
| -p 2222 | Port of the remote host. |
| -f | Install it without first checking whether it is already there. |
| -n | Dry run: print what would be appended and stop. |
Examples
ssh-copy-id -i ~/.ssh/id_ed25519.pub deploy@example.comAppend your key to the remote authorized_keys.
ssh-copy-id -p 2222 deploy@example.comThe same on a non-standard port.
When a connection fails, these narrow down how far it got — name not resolving, no route, or a blocked port.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does ssh-copy-id do?
Appends your public key to the server's ~/.ssh/authorized_keys so it stops asking for a password; password login has to still be open for that first run, and `-i` takes the `.pub` file, not the private key.
Q. How do I type it?
ssh-copy-id -i <key.pub> <user>@<host> — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
4 are listed here; the full set is in man ssh-copy-id. This command sits under Networking.
Related commands
man page: man ssh-copy-id