After we create ssh keys pair with 'ssh-keygen' command, the next step is to copy the public key to remote server and append in ~/.ssh/authorized_keys file.
$ scp ~/.ssh/id_dsa.pub firstname.lastname@example.org:
Login to remote server
$ mkdir .ssh --mode 700
$ cat ~/id_dsa.pub >> ~/.ssh/authorized_keys
$ chmod 600 .ssh/authorized_keys
Fast and simple Method using ssh-copy-id
ssh-copy-id is a script that uses ssh to log into a remote machine and append the indicated identity file to that machine's ~/.ssh/authorized_keys file creating the file, and directory, if necessary.
If your public key filename is anything other than id_rsa.pub you will get error stating "/usr/bin/ssh-copy-id: ERROR: No identities found". In this case you must provide the location and filename of the public key
$ssh-copy-id -i ~/.ssh/id_dsa.pub email@example.com
If remote server is listening on non-defaut port for ssh then,
$ssh-copy-id -i ~/.ssh/id_dsa.pub -p 5555 firstname.lastname@example.org
Post a Comment