OpenSSH server Authentication refused
Solution 1:
What about the message that is displayed twice in the debug logs:
Authentication refused: bad ownership or modes for directory /root
Fix the permissions of /root
and see where that takes you.
Solution 2:
I just had the exact same case: bad ownership on /xxx
(the top folder).
All the other usual ssh requirements were met in my case:
- no '
w
' for go anywhere (group or others) - 700 for
.ssh
- 600 for
.ssh/authorized_keys
And yet, an sshd -d
session consistently shown
Authentication refused: bad ownership or modes for directory /xxx
The only discrepency I found is that /xxx/yyy
was own by root
, while /xxx
was owned by "aUser
".
I did as root
a chown root:root /xxx
And the error went away.
Solution 3:
The problem was printed in your log:
Authentication refused: bad ownership or modes for directory /root
Check the permissions of the root user's home directory, /root
.
An example of working permissions from a live server:
error@www ~ $ ls -ld /root
drwx------. 6 root root 4096 Oct 16 19:12 /root
Solution 4:
A more comprehensive answer is found on this blog post: http://www.daveperrett.com/articles/2010/09/14/ssh-authentication-refused/
The TL;DR version of it is (the permissions are fairly specific):
chmod go-w /home/your-user
chmod 700 /home/your-user/.ssh
chmod 600 /home/your-user/.ssh/authorized_keys*
Additionally, if your user's home dir is a symlink, you want to follow it and chmod go-w / chmod 755 to that as well.