These steps are verified and tested several times and works flawlessly.
Install openssh server
sudo apt-get install openssh-server
Remove previous .ssh directory (from home directory)
rm -r ~/.ssh/
Now Execute the below command. Leave all the field empty when asked.
ssh-keygen -t rsa
Execute the following commands after that
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys sudo chmod go-w ~/ chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys exec ssh-agent bash ssh-add
That’s it.
You can test on your machine.
ssh-copy-id localhost
ssh localhost
When you ssh localhost, it will not ask you password again.