How to copy SSH public key to server
Mostly used for passwordless SSH
login; there are a few methods to copy your SSH
public key to the SSH server.
-
Use
SSH
‘s bundled command,ssh-copy-id
$ ssh-copy-id user@host
If you want to use other public key rather that then one in the default location,
use the-i
option as the following$ ssh-copy-id -i ~/.ssh/other_key.pub username@host
-
Manually append the content of your public key file (normally
~/.ssh/id_rsa.pub
to the server’s~/.ssh/authorized_keys
-
Using the following simple
Bash
script$ cat ~/.ssh/id_rsa.pub | ssh user@host 'cat >> ~/.ssh/authorized_keys