If you are trying to setup your public key for the purpose of authenticating automated logins, or just while trying to log into SSH you might experience the error:
SSH Authentication Refused: Bad Ownership or Modes for Directory
This error is primarily the result of a permissions issue. You can confirm this by tailing /var/log/secure on the target server/machine. For example:
tail -f /var/log/secure Mar 17 12:11:12 server sshd[3587469]: Authentication refused: bad ownership or modes for directory /home/user/.ssh
From the above output we can see the problem: bad ownership or modes for directory /home/user.ssh
On the plus side, this is an easy permissions fix. The error is because SSH doesn’t like it if your home or ~/.ssh directories has group write permissions. Your home directory should only be writeable by you and as such, ~/.ssh should have a permission value of 700 and authorized_keys should have a permission value of 600.
To achieve this, run:
chmod g-w /home/user
chmod 700 /home/user/.ssh
chmod 600 /home/user/.ssh/authorized_keys
Did you find this article helpful?
If you found this article helpful then you will love our support! Get blazing fast Shared Hosting and experience the HostDash difference today!
Check out our Shared Hosting plans today.
Have a Question?
We're here to help!
Email Us
Send us an email with your questions and we'll get back to you momentarily.
Send us an EmailSubmit a Ticket
Chat live with a member of our sales team to discuss your next project.
Submit a ticket