SSH key pair is a set of private/public keys used in securing network communication. These keys are normally required for passwordless SSH login to a remote host running SSH daemon (sshd). Here is how you would generate a pair of RSA keys:
$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/nirbhay/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/nirbhay/.ssh/id_rsa. Your public key has been saved in /home/nirbhay/.ssh/id_rsa.pub. The key fingerprint is: 5f:1a:b5:50:a8:b6:d6:2b:48:1b:b6:df:4c:54:a2:28 nirbhay@nirbhay-VirtualBox The key's randomart image is: +--[ RSA 2048]----+ | .. | | .. | | .o o | ... | .o. = . | | ...o | +-----------------+ $ ls ~/.ssh/ id_rsa id_rsa.pub
Now that we have the private/public key files, all you need to do is copy/append the public key (id_rsa.pub) contents to the remote machine’s ~/.ssh/authorized_keys (600) file. DO NOT share the “private key”.
Note: On debian-based distributions, ssh-keygen is provided by openssh-client package.