You should never add the file with the contents starting with -----BEGIN RSA PRIVATE KEY-----
, that’s your private key. You must put the public key in the ~/.ssh/authorized_keys
file.
This public key has the .pub
extension when generated using ssh-keygen
and the contents of the public key begins with ssh-rsa AAAA3B
The permissions of ~/.ssh
on the server should be 700. ~/.ssh/authorized_keys
on the server are supposed to be set to 600. The permissions of the key on the client-side should be 600.
If the private key was not protected with a password and you put it on the server, I recommend you generating a new one using:
ssh-keygen -t rsa
You can skip this if you’re fully sure that nobody can recover the deleted private key on the server.
If this does not help, run ssh
with options for more verbosity:
ssh -vvv user@example.com
On the server side, you can review /var/log/auth.log
for details.