For this tutorial I’ll be using the latest CentOS version, which is CenOS 6.4.
The first step is to generate a key if you don’t already have one. This can be achieved running:
and following the on-screen instructions.
If you already have a pair of keys, just append your public key in the
Now make the authorized keys readable only to the user:
chmod 600 ~/.ssh/authorized_keys
Now test your key-based login, and if it works then proceed to disabling password login.
Edit the sshd config file and change the following:
Protocol 2 PasswordAuthentication no UsePAM no
Now save the config file and restart the sshd server to apply the new settings. service sshd restart Now enjoy key-based authentification
service sshd restart