ssh RSA keys

Pre-requisite:

  • openssh-client
  • openssh-server

Procedure:

Generate public/private key pair:

First of all, we need to generate RSA key pair which will be shared with the remote server. It is a bit interactive process. Give the passphrase when asked.


      ssh-keygen -t rsa


SSH key Generation


Two file will be generated having names id_rsa (private key) & id_rsa.pub (public key) under ~/.ssh/ directory.


To verify run this command

      ls -l ~/.ssh

SSH key verification

Now copy the public key file to remote server..

      ssh-copy-id -i ~/.ssh/id_rsa.pub user@RemoteServerX


Verify that public key has been placed on remote server accurately. This can be either done by manually checking at the remote server whether the file is present or not or you can try to login remotely with the passphrase of the key.