17

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?

4
  • to round out the error-checking, what is the ownership of /root? ls -ld /root
    – Jeff Schaller
    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
    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.
    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
    Mar 3, 2023 at 7:05

1 Answer 1

18

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.

3
  • Thank you, it worked!
    – devzakir
    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
    Jul 22, 2022 at 23:04
  • even after 5 years, it works like magic !
    – YD8877
    Apr 4 at 18:48

You must log in to answer this question.

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