Securing SSH
Disabling password authentication in SSH is a good security measure. It prevents people from being able to log into the machine via ssh using a password. In order to log in you will need to get a key to the server that will then allow you to authenticate.
On the Client
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa -b 4096
This will create an SSH key pair on your client that you will use to authenticate. Note: The default bit length is 2048, so we pass the -b option to ssh-keygen to tell it we want a more secure key of 4096
Now to copy the key to the server using this command.
ssh-copy-id @
Where and should be replaced by your username and the name of the computer you're transferring your key to.
On the Server
On your server open for editing /etc/ssh/sshd_config
Change:
#PasswordAuthentication yes
to
PasswordAuthentication no
Then restart the SSH service
sudo /etc/init.d/ssh restart
now try to log into the server using the username we setup before, no password. If you try to log in with a username that has not been setup then you will get a Permission denied (publickey) message, which is what we want.