There are two steps.
1. Creating the SSH key on the local machine
2. Transferring the public key to the remote host and appending it to ~/.ssh/authorized_keys (which requires access to the remote machine)
$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/username/.ssh/id_rsa): Created directory '/home/username/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/username/.ssh/id_rsa. Your public key has been saved in /home/username/.ssh/id_rsa.pub. The key fingerprint is: f7:17:c6:4d:c9:ee:17:00:af:0f:b3:27:a6:9c:0a:05 username@slynux-laptop The key'srandomart image is: +--[ RSA 2048]----+ | . | | o . .| | E o o.| | ...oo | | .S .+ +o.| | . . .=....| | .+.o...| | . . + o. .| | ..+ | +-----------------+
The easiest way to upload is
ssh-copy-id USER@REMOTE_HOST
If ssh-copy-id is not available, do this instead:
$ ssh USER@REMOTE_HOST \ "cat >> ~/.ssh/authorized_keys" < ~/.ssh/id_rsa.pub Password:
To test that it works:
$ ssh USER@REMOTE_HOST uname