![Forrest logo](/images/logo.png)
ssh:tldr:4b38f
The command ssh-copy-id
is used to copy the user's public key to a remote server, allowing passwordless authentication for future SSH connections.
Here is the breakdown of the command:
ssh-copy-id
: This is the main command that facilitates copying the public key to the remote server.-i ${path-to-certificate}
: This option specifies the path to the user's public key certificate. The${path-to-certificate}
should be replaced with the actual path on your local machine.${username}@${remote_host}
: This represents the username and remote host where you wish to copy the public key.${username}
should be replaced with the desired username, and${remote_host}
should be replaced with the IP address or hostname of the remote server.
For example, if you have a certificate located at ~/.ssh/id_rsa.pub
, and you want to copy it to the remote server with the username user1
and IP address 192.0.2.123
, the command would look like this:
ssh-copy-id -i ~/.ssh/id_rsa.pub user1@192.0.2.123
Executing this command will prompt you for the password of the remote server's user. After providing the password, your public key will be appended to the ~/.ssh/authorized_keys
file on the remote server. From that point onwards, you should be able to log in to the remote server via SSH without entering a password, using the corresponding private key stored on your local machine.