ssh Authentication refused: bad ownership or modes

created at 06-04-2022 views: 7

problem

When setting up ssh password-free login, it is found that some machine settings do not take effect. Some machines are normal.

track

Log in to the target machine and view the log information of sshd. The log information directory is, /var/log/secure

You will find log messages like the following.

Jul 22 14:20:33 v138020.go sshd[4917]: Authentication refused: bad ownership or modes for directory /home/xxxx

reason

sshd requires the owner's directory and file permissions for security. If the permissions are incorrect, the password-free login of ssh will not take effect.

  • The user directory permissions are 755 or 700, but cannot be 77x.
  • .ssh directory permissions are generally 755 or 700.
  • rsa_id.pub and authorized_keys permissions are generally 644
  • rsa_id permission must be 600

solution

Check directory permissions, and set permissions as required for those that do not meet the requirements.

created at:06-04-2022
edited at: 06-04-2022: