This repository provides a PowerShell script to harden the OpenSSH Server configuration on Windows, making it more secure and resistant to known vulnerabilities like the Terrapin attack (CVE-2023-48795). The hardening measures are based on recommendations from SSH-Audit.
KexAlgorithms curve25519-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256
Ciphers [email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
MACs [email protected],[email protected],[email protected]
HostKeyAlgorithms [email protected],[email protected],[email protected],[email protected],rsa-sha2-512,rsa-sha2-256
CASignatureAlgorithms [email protected],ssh-ed25519,rsa-sha2-512,rsa-sha2-256
HostbasedAcceptedAlgorithms [email protected],[email protected],[email protected],rsa-sha2-512,[email protected],rsa-sha2-256
PubkeyAcceptedAlgorithms [email protected],[email protected],[email protected],rsa-sha2-512,[email protected],rsa-sha2-256
It is strongly recommended to upgrade to the beta version of the OpenSSH implementation for Windows using winget, which patches the Terrapin vulnerability (CVE-2023-48795).
winget install -e --id Microsoft.OpenSSH.Beta
To test which OpenSSH version you are currently running, run in a terminal:
ssh -V
Execute:
irm 'https://raw.githubusercontent.com/JuliusBairaktaris/Harden-Windows-SSH/main/ConfigureOpenSSH.ps1' | iex
- By launching ssh.exe with the -F parameter, specifying a path to a configuration file and an entry name from that file.
- A user's configuration file at %userprofile%.ssh\config.
- The system-wide configuration file at %programdata%\ssh\ssh_config.
hmac-sha2-256
: This MAC is necessary to connect to the default SSH configuration of OpenWRT, Debian, DietPi, and other similar systems.
Security Scores using SSH-Audit
Default OpenSSH v8.X Configuration:
Hardened OpenSSH v8.X Client Configuration:
Default OpenSSH v8.X Server Configuration:
Hardened OpenSSH v8.X Server Configuration:
To further secure Windows, check out the great Harden-Windows-Security module by HotCakeX.