1

I have read through about a dozen other similar threads and nothing in those are helping me resolve my issue.

On Windows client, using PuttyGen to set up SSH-2 RSA Keys. And then set the putty session to use SSH/Auth/newKeys file.

On linux, i set up /home/user/.ssh/authorized_keys file and copied the public putty key to the file. chmod go-r authorized_keys and then in $home directory chmod 700 .ssh. Permissions should now all be set.

On linux /etc/ssh/sshd_config file, verified AuthorizedKeysFile .ssh/authorized_keys is properly set. I do want to point out that PasswordAuthentications yes is still set, but that shouldn't matter should it, once keys are defined, ssh will use those first...or am I wrong?

As suggested in a comment, I found this in /var/log/secure for that users authorized_keys file:

Authentication refused: bad ownership or modes for file

Directory and file permissions are

drwx------ 2 userID userID 29 Apr 27 07:36 .ssh
-rw--w---- 1 userID userID 393 Apr 27 07:36 authorized_keys

What's wrong here?

4
  • 1
    Look at /var/log/secure on the server side for errors and warnings as you try to connect. If you don't understand the messages please post them (as text) in your question. Apr 27, 2020 at 15:16
  • And on the client side, see the debug log output, I don't know how to do that with putty though...
    – pLumo
    Apr 27, 2020 at 15:17
  • @roaima - thanks. That pointed me to the following log message: Authentication refused: bad ownership or modes for file for that users authorized_keys file. Directory permissions are: drwx------ 2 userID userID 29 Apr 27 07:36 .ssh and file permissions are: -rw--w---- 1 userID userID 393 Apr 27 07:36 authorized_keys - what do I have wrong here?
    – rolinger
    Apr 27, 2020 at 15:32
  • Stalin Vignesh Kumar's answer below did the trick.
    – rolinger
    Apr 27, 2020 at 15:35

1 Answer 1

3

Your authorized_keys file should have exactly 640 permission

chmod 640 authorized_keys

should have to be exactly like below :

-rw-r-----.
4
  • that did the trick. Thanks. I got the chmod go-r authorized_keys from a tutorial. didn't occur to me the tutorial would be wrong.
    – rolinger
    Apr 27, 2020 at 15:36
  • Pleasure ... yeah sometimes ... i faced this issue recently ...glad it helped... Apr 27, 2020 at 15:38
  • 1
    In the tutorial that - should be = (at best). Or better chmod u=rw,go= authorized_keys Apr 27, 2020 at 16:03
  • For the benefit of those brought here searching for a slightly different question, Authentication refused: bad ownership or modes for directory… under certain odd circumstances may be about the ownership of the home directory, not its mode. Aug 4, 2021 at 22:23

You must log in to answer this question.

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