ssh-copy-id
TLDR
Copy the default public key to a remote host
SYNOPSIS
ssh-copy-id [-f] [-n] [-s] [-i identityfile] [-p port] [-o sshoption] [user@]hostname
DESCRIPTION
ssh-copy-id installs SSH public keys on a remote server's authorizedkeys file, enabling passwordless authentication. It connects via SSH (usually with password authentication), creates the ~/.ssh directory and authorizedkeys file if needed, and appends your public key.
The script ensures correct permissions are set: ~/.ssh directory at 700 and authorized_keys at 600, which SSH requires for security. Incorrect permissions cause authentication failures.
By default, ssh-copy-id uses keys from ssh-add -L or the most recent ~/.ssh/id*.pub file. Use -i to specify a different key.
PARAMETERS
-i identityfile_
Use the specified identity file (public key)-p port
Connect to the specified port on the remote host-f
Force mode; don't check if keys already exist on remote-n
Dry run; print keys that would be installed without installing-s
Use sftp instead of cat for copying (useful for restricted shells)-o sshoption_
Pass options to the underlying ssh command
CAVEATS
Password authentication must be enabled on the remote host for the initial copy. After installation, you may want to disable password authentication in sshd_config. The script is a shell wrapper around ssh, so all ssh options apply.
HISTORY
ssh-copy-id is a convenience script included with OpenSSH to simplify the public key installation process. It automates what would otherwise require manually copying keys and setting permissions correctly.
SEE ALSO
ssh(1), ssh-keygen(1), ssh-add(1), sshd_config(5)


