Forrest logo
back to the ssh-copy-id tool

ssh:tldr:90674

ssh: Copy the given public key to the remote with specific port.
$ ssh-copy-id -i ${path-to-certificate} -p ${port} ${username}@${remote_host}
try on your machine

This command is used to copy the public key of your local machine to a remote machine, allowing you to authenticate your remote connections using SSH key-based authentication rather than password authentication.

Here's the breakdown of the command with its options:

  • ssh-copy-id: This is the main command that performs the key copying operation.
  • -i ${path-to-certificate}: This option specifies the path to the local SSH public key certificate that you want to copy. Replace ${path-to-certificate} with the actual path and filename of your public key certificate file.
  • -p ${port}: This option specifies the port number on which the SSH service of the remote machine is running. Replace ${port} with the actual port number. By default, SSH uses port 22 for communication.
  • ${username}@${remote_host}: This is the username and hostname or IP address of the remote machine where you want to copy your public key. Replace ${username} with your remote username and ${remote_host} with the IP address or hostname of the remote machine.

When you execute this command, it prompts you for the password of the remote user account. After successful authentication, it copies your public key to the appropriate location on the remote machine, typically in the ~/.ssh/authorized_keys file. This allows you to log into the remote machine without entering a password, as long as your local private key matches the copied public key.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the ssh-copy-id tool