更新Windows自带的OpenSSH

# 从GitHub Release下载最新版本的OpenSSH for Windows
$url = "https://github.com/PowerShell/Win32-OpenSSH/releases/latest/download/OpenSSH-Win64.zip"
Invoke-WebRequest -Uri $url -OutFile ".\OpenSSH-Win64.zip"

# 获取文件夹权限
takeown.exe /a /r /f C:\Windows\System32\OpenSSH\
icacls.exe 'C:\Windows\System32\OpenSSH' /grant 'BUILTIN\Administrators:(OI)(CI)F'
icacls.exe 'C:\Windows\System32\OpenSSH' /grant 'BUILTIN\Administrators:F' /t

Stop-Service ssh-agent

# 解压缩并拷贝到相应文件夹
Expand-Archive -Path ".\OpenSSH-Win64.zip" -DestinationPath .
$openSshBins = (Get-ChildItem 'C:\WINDOWS\System32\OpenSSH\').Name
$openSshBins | %{ Copy-Item -Path .\OpenSSH-Win64\$_ -Destination C:\Windows\System32\OpenSSH\ }
## 可能有遗漏,需检查

Start-Service ssh-agent

参考: https://superuser.com/questions/1395962