I'm trying to SSH into my remote VPS with Debian onboard. Running sshd in debug mode, I found that:

Authentication refused: bad ownership or modes for directory /root

I tried setting permissions as I found in Google:

chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

But it still refuses auth with pubkey and asks for password, with the same message in debug. What am I doing wrong?

  • to round out the error-checking, what is the ownership of /root? ls -ld /root – Jeff Schaller Oct 23 '19 at 12:56
  • Additionally, according to unix.stackexchange.com/a/36687/117549, your home directory (/root here) must only be readable to you, so go-w may not be enough. – Jeff Schaller Oct 23 '19 at 12:57
  • Re-run your chmod commands referencing /root/ explicitly. It is not clear from your context what ~/ is. Do chmod go-w /root/, etc. And as @JeffSchaller requests, edit your post to add the output of ls -ld /root and ls -ld /root/.ssh – Jim L. Oct 23 '19 at 18:06

Well, I should really thank @jeff-schaller, it was broken ownership of folder. I've done

chown root /root
chown root /root/.ssh

And from there it worked flawlessly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.