I've set up OpenSSH on various flavors of Linux tons of times. But I can't for the life of me get it functioning correctly on windows.
There seem to be two sides to the issue. The permissions and the key used by
Every page I read has a different answer for the correct permissions. Some work, and sometimes the program complains about them.
From what I understand the keys should all be owned by
SYSTEM, with read access for
NT SERVICE\sshd and Full Control for
SYSTEM? (As I understand
Administrators represent root in Windows). I read in the documentation that the read access is only necessary if not using
ssh-agent. I also configured the same permissions for the
%USERPROFILE%/.ssh/authorized_keys file and added the
.pub the Ed25519 key which is the one I'm using to try and connect, though I've also tried it with my own generated RSA key.
With the permissions set this way the program doesn't complain when adding keys to the agent or running the daemon. The only option I changed in
sshd_config is the
ListenAddress which was binding to 0.0.0.0, I set it to the machines local IP as SSH will only be used locally.
When I run
sshd.exe with the
-d option, I notice it importing the 4 default keys from
%PROGRAMDATA%/ssh. When I added the
ed25519.pub key to
authorized_keys it was followed by
HOSTNAME being my PC's hostname. Normally I would expected to see
user@host. I tried creating my own key and adding it but when I run
sshd.exe -d it never seems to use anything other than the default keys.
In the end, I'm unable to connect to the OpenSSH server, and the logs in
%PROGRAMDATA%/ssh/Logs only seem to show the server starting. To sum up my questions: What are the correct permissions for the key files and
authorized_hosts? Does the annotation in
authorized_keys being wrong make a difference? Should I be adding all of the default keys
authorized_hosts? And last, what does
sshd mean when it mentions those keys during startup (see log)? Shouldn't my own generated key just work as long as I add it to
debug1: sshd version OpenSSH_for_Windows_7.6, LibreSSL 2.6.4 debug1: private host key #0: ssh-rsa SHA256:and12LVkEqyXJ2gr0SxFEQObaSFF+Czlcnx2uFjZaJQ debug1: private host key #1: ssh-dss SHA256:waeLdy4Sm3NT+zbwEMIhbfl8TLe6WeQ0MuZE07CzFQU debug1: private host key #2: ecdsa-sha2-nistp256 SHA256:G8/7y/04cSE3EezTrcmpK4lRmJ5f5I/CDPcHaPzsv4o debug1: private host key #3: ssh-ed25519 SHA256:Jvn9UjsbdzH54L/yvGYGfCzJQVIMiIWL5RETbaL2ACA debug1: rexec_argv='C:\\WINDOWS\\System32\\OpenSSH\\sshd.exe' debug1: rexec_argv='-d' debug1: Bind to port 22 on 192.168.1.144. Server listening on 192.168.1.144 port 22.