SSH Authentication Refused: Bad Ownership or Modes for Directory

Reason : You most likely have set the ownership permissions to 777 or something similar. .ssh folder must be set to 700.
How to find out : Tail your logs. sudo tail -f /var/log/secure You can get warnings similar to this. Authentication refused: bad ownership or modes for directory /home/kmdarshan/.ssh.
Solution :
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Edge cases : Lets see your using google compute or similar remote terminals to login, then your pretty much screwed. Since they wouldn’t let you login. Then you need to do it this way:

$ whoami
user1
$ su - user2
Password:
$ whoami
user2
$ exit
logout

This would change the permissions and allow you to login.

In

Leave a Reply

Your email address will not be published. Required fields are marked *