16

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?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
keddad
  • 523
  • 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 https://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
  • 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 03 '23 at 07:05

1 Answers1

17

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.

keddad
  • 523