I would first check SSH config, it could be that somehow is wrong there and it’s ignoring keys.
Open config file with you favorite editor:
- sudo nano /etc/ssh/sshd_config
Now verify that following settings are as this:
sshd_config - Important settings
Make sure it is set as above and it’s uncommented (doesn’t have
# in beginning of line).
If you changed something make sure you restart SSH:
If you want to clean up all keys, you can delete
~/.ssh/authorized_keys, than you can try again. I recommend you to copy keys with
ssh-copy-id if that’s possible.
This tutorial can be a good reading and I recommend it.
If you do manual way, you can verify file permissions:
- sudo chmod 700 ~/.ssh
- sudo chmod 600 .ssh/authorized_keys
SSH, or secure shell, is the most common way of administering remote Linux servers. Although the daemon allows password-based authentication, exposing a password-protected account to the network can open up your server to brute-force attacks. In this guide, we demonstrate how to configure your server with SSH keys, which is the recommended authentication method. These are much more difficult for attackers to work around, giving you a more secure login mechanism.