在Windows Server 2016 1709上安装OpenSSH
独立安装
powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
以下为记录(在Winodws 2016 DataCenter版本没有测试成功)
参考
Last updated
powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1
Last updated
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22net start sshdSet-Service sshd -StartupType Automatic
Set-Service ssh-agent -StartupType AutomaticNew-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShellCommandOption -Value "/c" -PropertyType String -ForceGet-WindowsCapability -Online | ? Name -like 'OpenSSH*'Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0Start-service ssh-agentGet-service ssh*Restart-servercd C:\Windows\System32\OpenSSH
.\ssh-keygen -A
.\ssh-add ssh_host_ed25519_key
Install-Module -Force OpenSSHUtilsRepair-SshdHostKeyPermission -FilePathStart-Service sshdInstall-Module -Force OpenSSHUtilsRepair-SshdHostKeyPermission -FilePath C:\Windows\System32\OpenSSH\ssh_host_ed25519_keyNew-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Service sshd -Enabled True -Direction Inbound -Protocol TCP -Action Allow -Profile Domain