Passwordless SSH on Ubuntu Linux


These steps are verified and tested several times and works flawlessly.

  1. Install openssh server
sudo apt-get install openssh-server
  1. Remove previous .ssh directory (from home directory)
rm -r ~/.ssh/
  1. Now Execute the below command. Leave all the field empty when asked.
ssh-keygen -t rsa
  1. Execute the following commands after that
cat ~/.ssh/ >> ~/.ssh/authorized_keys
sudo chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
exec ssh-agent bash

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.

Published in: Ubuntu
Originally Published On : Apr 25, 2017