Generate your SSH key:
$ ssh-keygen -t rsa
Copy over to destination host:
$ scp ~/.ssh/id_rsa.pub user@host:~/.ssh
Login to remote host (still using password):
$ ssh user@host user@host's password: $ cd ~/.ssh $ cat ./id_rsa.pub >> ./authorized_keys $ rm -f ./id_rsa.pub $ chown 600 ./authorized_keys
Logout and try login again:
$ ssh user@host Enter passphrase for key '/home/localusr/.ssh/id_rsa':
That’s it. Enter the passphrase and you can login using your key.
Resources
- Using SSH Keys
- Be your own Certificate Authority (CA)
- Setup the SSH server to use keys for authentication
- Securing OpenSSH (CentOS)
SSH Login Using Keys