Ssh Use Locally Available Keys to Authorize Logins on a Remote Machine

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

Overview

ssh-copy-id is a script that uses ssh to log into a remote machine, either via login password or using previously configured identities. It then assembles a list of the identities that failed to log in and using ssh enables logins with those keys on the remote server. By default it adds the keys by appending them to the remote user's ~/.ssh/authorized_keys, creating the file and directory as necessary.

ssh-copy-id -i <identity-file> <user>@<remote-host>

Identity file should be the private key.

If you have access to the remote host via a different identity, access can be set based on a public key alone:

ssh-copy-id -f -i <public-key-file> <user>@<remote-host>