Did you know?
ssh-copy-id installs your SSH key on a server in one command.
It creates ~/.ssh with the right permissions and appends your key to authorized_keys.
- Security & SSH
- Last checked
Explained
Setting up key-based login by hand means creating ~/.ssh, pasting the key into authorized_keys and getting the permissions exactly right, or SSH silently ignores the key. ssh-copy-id does all of it:
ssh-keygen -t ed25519ssh-copy-id user@server
It logs in once with your password, copies your public key and sets the permissions (700 on the directory, 600 on the file). Then test it:
ssh user@server
If you have several keys, choose one with -i ~/.ssh/id_ed25519.pub, and use -p 2222 for a non-standard port. ssh-copy-id skips keys that are already installed, so running it twice is harmless.
Once key login works for every account you need, consider turning off password logins in /etc/ssh/sshd_config with PasswordAuthentication no. Keep a second session open while you test, so a mistake doesn’t lock you out.
Learn more
- How To Set Up SSH Keys in Linux Full guide · Updated Apr 2025
-
sshcommand cheat sheet Options and copy-ready examples
