If you get this error in your logs when trying to set up public key authenticated automatic logins, or while trying to SSH into your account, after setting up the public key the issue is related to permissions.
Tailing /var/log/secure on the target machine will be useful:
tail -f /var/log/secure Dec 26 12:30:38 server sshd[3503454]: Authentication refused: bad ownership or modes for directory /home/user/.ssh
As you can see – bad ownership or modes for directory /home/user/.ssh.
SSH doesn’t like it if your home or ~/.ssh directories have group write permissions. Your home directory should be writable only by you, ~/.ssh should be 700, and authorized_keys should be 600 :
chmod go-w /home/user chmod 700 /home/user/.ssh chmod 600 /home/user/.ssh/authorized_keys
So fixing permissions is the way to go and have this error resolved.
Tired of hassling with troubleshooting? ChemiCloud is the managed hosting solution designed to save you time and money! 🤓 Check out our web hosting plans!
But how to make sshd accept authentication if I WANT AND NEED my home directory to be group writable?
Ty so musch for this
Easy and straightforward. It works perfect and fixed my problem. Now I can continue with Ansible. Thanks
Search for the solution for 3 days, finally
Thank you
Thanks for pointing this out! We’ve updated the KB!
You’ll actually want: chmod go-w /home/user
chmod g-w /home/user didn’t cut it for me
That did the trick!
Thanks!
Thank you, you hit the point
Glad to hear that you’ve managed to sort things out, David. If you ever need a more reliable host, we would love to help!
Finally the RIGHT answer to my problem!!!!
I was never able to find anyone who gave me the correct set of perms that the sshd appreciated.
THANK YOU!!