Search code examples
sshwindows-10openssh

Cannot connect to Windows 10 over SSH running OpenSSH


I have a Windows 10 machine running OpenSSH that I need to connect to over SSH using PuTTY. I have created a public/private key on the Host machine using PuTTYgen. I loaded the public into the user's profile directory under .ssh/authorized_keys. When I connect with PuTTY from a machine outside the network I get this error message:

"Server refused our key"

I have read several posts and they all indicate the public key is not being read correctly. I have made the following changes with no success.

  1. Update user permissions on .ssh and /authorized_keys setting the User as the owner.
  2. Currently my .ssh folder is located in %SYSTEMDRIVE%/users/[USERNAME]/.ssh
  3. I recreated this directory on my data drive to be sure that was not an issue: "D:/users/[USERNAME]/.ssh
  4. Because the account I am using is an administrator account I have created "%Program Data/ssh/adminstrators_authorized_keys
  5. I commented out the line in sshd_config that looks at the file in #4 when the user is an administrator.

None of these attempts have cleared up the problem. I have never set up SSH on a Windows 10 host before so I am out of ideas. I set up logging in sshd_config but there are no log files being generated.

Can someone help me get this figured out?


Solution

  • First, as in this tutorial, make sure to copy an OpenSSH public key

    The OpenSSH public key is located in the box under Key / Public key for pasting info OpenSSH authorized_keys file:. The public key begins with ssh-rsa followed by a string of characters.

    Second, as in this gist, launch sshd -d to get a one time session in debug mode: you will see more clues as to why it rejects your public key.


    The OP gacto confirms in the comments:

    sshd -d gave me the information I needed.

    It was a file permissions issue. I had set the file permissions to the specifications from the OpenSSH setup instructions, but access to the file was getting blocked.
    Once I updated the file permissions, I was able to connect without any trouble.