Contents

Generate an SSH key on Windows

Use the following command in PowerShell to generate your key.

ssh-keygen -t ed25519 -C "User-OS-Hostname"

Install OpenSSH Server on Windows Server

On the Windows Server (PowerShell as Administrator):

Use PowerShell 5.1.
Newer PowerShell versions struggle with the command due to lack of support for the old COM object architecture.

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Then:

Start-Service sshd
Set-Service sshd -StartupType Automatic

Check it’s running:

Get-Service sshd

And open port 22 in the firewall:

New-NetFirewallRule -Name sshd -DisplayName "OpenSSH Server" -Protocol TCP -LocalPort 22 -Action Allow

Copy your public key to the server

On your PC

Show the public key:

type $env:USERPROFILE\.ssh\id_ed25519.pub

Copy the entire line.

On the server

Create the authorized_keys file in nano.

nano C:\ProgramData\ssh\administrators_authorized_keys
  1. Paste your public key (single line)
  2. Save
  3. Fix permissions (critical):
    icacls C:\ProgramData\ssh\administrators_authorized_keys /inheritance:r
    icacls C:\ProgramData\ssh\administrators_authorized_keys /grant SYSTEM:F
    icacls C:\ProgramData\ssh\administrators_authorized_keys /grant Administrators:F
    
  4. Restart SSH:
    Restart-Service sshd
    

Test SSH login

From your PC:

ssh -i C:\Users\Ronny\.ssh\id_ed25519 Ronny@SERVER_IP
  • First time → accept host fingerprint
  • Enter key passphrase
  • You should log in without a password prompt

Use the key in WinSCP

WinSCP settings

  • Protocol: SFTP
  • Host: SERVER_IP
  • Username: Ronny
  • Advanced → SSH → Authentication
    • Private key file:
      C:\Users\Ronny\.ssh\id_ed25519
      

Connect → enter key passphrase → done.

On first use of the key, WinSCP will convert it to the puTTY-format (.ppk).
Store the .ppk private key in the same place as the OpenSSH format private key.

Optional but recommended

Disable password logins

On the server:

nano C:\ProgramData\ssh\sshd_config

Set:

PasswordAuthentication no
PubkeyAuthentication yes

Restart SSH:

Restart-Service sshd

Now only your key can get in.

Pro tips for video transfers

  • In WinSCP:
    • Preferences → Transfer → Enable resume
    • Increase buffer size
  • Consider one directory dedicated to uploads (NTFS permissions stay sane)