On the remote machine (machine to be sshed) execute:
ssh-keygen -t rsa
Press <Enter> key twice. One for public/private key file path and other for passphrase.
If required you can enter the passphrase.
By default, two keys will be created as follows:
$HOME/.ssh/id_rsa (private) and $HOME/.ssh/id_rsa.pub (public)
Create a pem key with the following command:
openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem
Edit the /etc/ssh/sshd_config file change as the following:
RSAAuthentication yes
PubkeyAuthentication yes
then restart ssh service : service sshd restart
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
Copy the pem file to the machine from where you want to ssh the remote machine.
chmod 400 id_rsa.pem
Then ssh with:
ssh -i id_rsa.pemĀ <remote m/c IP>