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
    Commented Oct 23, 2019 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
    Commented Oct 23, 2019 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.
    Commented Oct 23, 2019 at 18:06
  • It works, but ssh service display log: ssh.service: Found left-over process 1704 (sshd) in control group while starting unit. Ignoring. and This usually indicates unclean termination of a previous run, or service implementation deficiencies.
    – Seiden
    Commented Mar 3, 2023 at 7:05

1 Answer 1


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.

  • Thank you, it worked!
    – devzakir
    Commented Jan 26, 2022 at 2:02
  • 4
    I had to use both: </br> <pre> chown root /root chown root /root/.ssh And then: chmod go-w ~/ chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys It worked after that.
    – Damon Hill
    Commented Jul 22, 2022 at 23:04
  • even after 5 years, it works like magic !
    – YD8877
    Commented Apr 4 at 18:48
  • The user and the group should belong to the owner, I had to use chown usr:usr /home/usr
    – Nir
    Commented Apr 29 at 13:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .