When configuring SSH keys to be able to login to a server without a password you mighkeys2t run into a permissions error. If the authorized_keys or authorized_keys2 file has the incorrect permissions it will not authenticate with your ssh-rsa key but instead still require a password. If you are having trouble configuring SSH keys you should check the /var/log/secure file to see if there is an error displaying in that log. You may see the error displayed below.
Error: Authentication refused: bad ownership or modes for file .ssh/authorized_keys
If you see this error it means that the authorized_keys or authorized_keys2 file has the incorrect ownership or permissions. Make sure that the authorized_keys file is owned by the user that will be logged into and the permissions are 600. So if the username is backup you would want the file to look like the below when issuing the “ls -alh” command.
- -rw------- 1 backup backup 409 Mar 23 19:56 authorized_keys
If the ownership or permissions are different than the above you can accomplish setting the proper ownership and permissions by using the below two commands.
- chown backup.backup authorized_keys
- chmod 600 authorized_keys
That should resolve your problems and now from the remote server you should be able to SSH to this server and login without a password.