Forrest logo
back to the ssh-copy-id tool

ssh:tldr:454a7

ssh: Copy your keys to the remote machine.
$ ssh-copy-id ${username@remote_host}
try on your machine

The command "ssh-copy-id" is used to install your public key on a remote machine. This allows you to authenticate your SSH sessions to that machine using your private key instead of providing a password.

Here is an explanation of the different parts of the command:

  • ${username@remote_host}: This is a placeholder indicating that you need to replace it with the actual username and remote hostname or IP address. For example, if your username is "john" and the remote host is "example.com", you would replace this placeholder with "john@example.com".

When you run the command, it will try to connect to the remote host using SSH and prompt you for your account password. Once you provide the correct password, it will copy your public key (located in the ~/.ssh/id_rsa.pub file by default) to the remote machine and add it to the authorized_keys file in the remote user's ~/.ssh/ directory.

After running the ssh-copy-id command, you should be able to log in to the remote machine using SSH without having to provide a password, as long as your private key (~/.ssh/id_rsa) matches the public key installed on the remote machine.

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