nem.ec

Programming Information Security Recipes Personal Code Snippets

Install SSH on Windows 10 and enable key-based authentication

Setup SSH

Source: https://winscp.net/eng/docs/guide_windows_openssh_server

New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' `
    -Enabled True -Direction Inbound -Protocol TCP -Action Allow `
    -LocalPort 22 -Program "C:\System32\OpenSSH\sshd.exe"

Enable Key Authentication

Source: https://github.com/PowerShell/Win32-OpenSSH/wiki/Security-protection-of-various-files-in-Win32-OpenSSH

For administrator user:

cd C:\ProgramData\ssh\
New-Item administrators_authorized_keys
# Copy-paste public key (e.g. ~/.ssh/id_rsa.pub) entry into this file
icacls administrators_authorized_keys /inheritance:r
icacls administrators_authorized_keys /grant SYSTEM:`(F`)
icacls administrators_authorized_keys /grant BUILTIN\Administrators:`(F`)