SSH Authentication refused: bad ownership or modes for file /home/user/.ssh/authorized_keys2

The error message “Authentication refused: bad ownership or modes for file /home/user/.ssh/authorized_keys2” indicates that there is a problem with the permissions of the authorized_keys file on the server.

To fix this error, you need to adjust the ownership and permissions of the authorized_keys file. Follow these steps:

  1. Connect to the server via SSH using your username and password.
  2. Check the ownership and permissions of the .ssh directory and the authorized_keys file:
    ls -la ~/.ssh
    ls -la ~/.ssh/authorized_keys*

    The ownership of the .ssh directory should be set to the user’s account, and the permissions should be set to 700. The authorized_keys file should be owned by the user and the permissions should be set to 600.

  3. If the ownership and permissions are incorrect, you can fix them using the following commands:
    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys*
    chown user:user ~/.ssh/authorized_keys*

    Replace “user” with the username of the account that you are using to connect to the server.

  4. Try connecting to the server again. The error message should no longer appear. (perfumesample.com)

If you continue to experience issues, ensure that the SSH daemon configuration file is correct, and that the settings for the user accounts and SSH access are properly configured.

Leave a Comment