Fix: SSH Authentication Refused: Bad Ownership or Modes for Directory

If you are configuring SSH key based authentication, whether for automated access or direct logins, you may encounter the following error:

SSH Authentication Refused: Bad Ownership or Modes for Directory

This message typically indicates that file or directory permissions are not correctly set. To verify this, you can examine the system log on the destination server. For example:

tail -f /var/log/secure

You may see output similar to the following:

May 21 12:00:00 server sshd[3587469]: Authentication refused: bad ownership or modes for directory /home/user/.ssh

This clearly points to a permissions-related issue with the .ssh directory.

The Issue & Fix

SSH enforces strict permission settings on the user’s home and .ssh directories. If these directories or the authorized_keys file are writable by group or others, SSH will reject the login attempt for security reasons.

To correct this, ensure that:

- Your home directory is not group-writable
- The .ssh directory has permissions set to 700
- The authorized_keys file is set to 600

You can apply the appropriate permissions with the following commands:

chmod g-w /home/user
chmod 700 /home/user/.ssh
chmod 600 /home/user/.ssh/authorized_keys

After applying these changes, retry your SSH login. The issue should be resolved if all permissions are set correctly.

If you continue to experience problems, please contact our support team for further assistance.

Get Shared Hosting
Monthly Business Growth Tips

Receive monthly top tips on how to grow and scale your web business.

No Spam. Unsubscribe Anytime.

Did you find this article helpful?

If you found this article helpful then you will love our support!
Get blazing fast web hosting and experience the AblePage difference today!