The procedure to set this up is extremely simple. I’ll be showing you this on a Ubuntu Server install with OpenSSH but the procedure is similar on other setups. On a Ubuntu server the file will be located in /etc/ssh/sshd_config. your going to want to add the following to the config file (or change the values if they already exist.
ChallengeResponseAuthentication no PasswordAuthentication no UsePAM no
Once you save the changes you’ll need to reload the SSH server with the following command.
Update 07/17/2012: Thanks to a reeder who pointed out something I missed, Ensure you’ve enabled public key authentication, I’ve noted that most often this is enabled by default but if its not YOU WILL lock yourself out. ensure the following is set in your configuration.
And then reload the SSH Service.
User@Host:~$ /etc/init.d/sshd reload
Thats it, your server should no longer accept user name/password authentication.