ssh-copy-id
Install your public key in a remote account’s authorized_keys.
Before you run
Requires an existing way to authenticate, often an account password, and a writable remote home with a compatible shell. This utility is not included in every macOS or Windows installation; check availability before use. Copy only the .pub file. Installation adds an authorized key; it does not disable password login or configure OTP.
Examples
Install this public key using the default SSH port.
ssh-copy-id -i ~/.ssh/id_ed25519.pub alice@server.example.comInstall the same key on a server using port 2222; then test ssh -p 2222.
ssh-copy-id -p 2222 -i ~/.ssh/id_ed25519.pub alice@server.example.comOptions and examples
-i identity_fileCommonSelect the public key to install on the server. Do not copy the private key.
ssh-copy-id -i ~/.ssh/id_ed25519.pub alice@server.example.com-p portCommonConnect to the server on the specified SSH port.
ssh-copy-id -p 2222 -i ~/.ssh/id_ed25519.pub alice@server.example.com-nPerform a dry run without installing keys; availability varies by version.
ssh-copy-id -n -i ~/.ssh/id_ed25519.pub alice@server.example.com-fForce installation without checking whether the key is already present; duplicates may result.
ssh-copy-id -f -i ~/.ssh/id_ed25519.pub alice@server.example.com-o optionPass an SSH client configuration option to the connection.
ssh-copy-id -o ConnectTimeout=10 -i ~/.ssh/id_ed25519.pub alice@server.example.com-F configfileUse an alternative SSH client configuration file.
ssh-copy-id -F ~/.ssh/lab_config alice@server.example.comAuthoritative references
Reviewed October 27, 2026