I have a VPS with CentOS 6. I've noticed a lot of login attempts via SSH, so I want to lock it down with key based authentication. Here is what I have done so far....
Ran the following on my client machine (OSX)
ssh-keygen -t rsa
Did this with default settings (no passphrase, default names, etc)
Set the following permissions on my client
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
copied my public key to the root of my userfolder on my VPS using the following command (fake name/ip)
scp id_rsa.pub fakeuser@255.255.255.255:/home/fakeuser/id_rsa.pub
Here I noticed that I did NOT have an authorized_keys file within my .ssh. So I used touch to create it. Then I used CAT to copy the contents of the .pub into the authorized_keys file
cat id_rsa.pub >> ~/.ssh/authorized_keys
and set the appropriate permissions on .ssh and authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
In /etc/ssh/sshd_config I uncommented the following
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
I then restarted sshd
service sshd restart
From what I read, this is all I should have to do to enable public key authentication. However, when I attempt to SSH without supplying -i privatekey, I am allowed in from all devices.
pi:raspberry
anyone?) - but it's definitely better to not allow passwords at all for SSH.