Install your SSH public key with ssh-copy-id

Skip the manual cat >> authorized_keys dance — ssh-copy-id pushes your public key to a server and fixes permissions in one shot.

LinuxsshauthkeysLow risk
Run `ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server`, enter your password once, and future logins use the key.

01Command

Command
$ ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server

02What it does

ssh-copy-id appends your chosen public key to the server's ~/.ssh/authorized_keys and, critically, sets the correct file and directory permissions that sshd silently requires. With `-i` you pick exactly which key to install (always specify the `.pub` file) instead of dumping every identity. If the server uses a nonstandard port, pass it SSH-style: `ssh-copy-id -p 2222 user@server` or `-o 'Port 2222'`.

03Risk

RiskLow risk
Requirementsssh-copy-id; password access to the target account for the first copy

04Undo

Undo
$ Remove the appended line from ~/.ssh/authorized_keys on the server.

05Sources

Last verified: 2026-09-17 · Category: Network