Last active
April 8, 2026 14:09
-
-
Save qnzkrew/10e894ba8564dd71b2aaa4b5d41a6fd8 to your computer and use it in GitHub Desktop.
Enable SSH+WinRM on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| echo Checking admin... | |
| net session >nul 2>&1 || (echo RIGHT-CLICK THIS FILE AND RUN AS ADMINISTRATOR & pause & exit /b 1) | |
| echo Installing SSH Server... | |
| powershell -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0" | |
| echo Starting SSH... | |
| sc config sshd start=auto | |
| net start sshd | |
| echo Enabling WinRM... | |
| powershell -Command "Enable-PSRemoting -Force -SkipNetworkProfileCheck" | |
| echo Opening firewall... | |
| netsh advfirewall firewall add rule name="SSH-Remote" dir=in action=allow protocol=tcp localport=22 | |
| netsh advfirewall firewall add rule name="WinRM-Remote" dir=in action=allow protocol=tcp localport=5985 | |
| netsh advfirewall firewall add rule name="Allow-Ping" dir=in action=allow protocol=icmpv4 | |
| echo. | |
| echo DONE! SSH and WinRM should be active now. | |
| pause |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Enable SSH + WinRM for remote management | |
| # Run as Administrator | |
| Write-Host "Enabling OpenSSH Server..." -ForegroundColor Cyan | |
| Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 | |
| Start-Service sshd | |
| Set-Service -Name sshd -StartupType Automatic | |
| Write-Host "Enabling WinRM..." -ForegroundColor Cyan | |
| Enable-PSRemoting -Force -SkipNetworkProfileCheck | |
| Write-Host "Opening firewall ports..." -ForegroundColor Cyan | |
| New-NetFirewallRule -DisplayName "SSH-Remote" -Direction Inbound -LocalPort 22 -Protocol TCP -Action Allow -RemoteAddress 192.168.113.0/24,100.64.0.0/10 | |
| New-NetFirewallRule -DisplayName "WinRM-Remote" -Direction Inbound -LocalPort 5985,5986 -Protocol TCP -Action Allow -RemoteAddress 192.168.113.0/24,100.64.0.0/10 | |
| New-NetFirewallRule -DisplayName "Allow-Ping" -Direction Inbound -Protocol ICMPv4 -Action Allow | |
| Write-Host "`nDone! Status:" -ForegroundColor Green | |
| Write-Host "SSH: $((Get-Service sshd).Status)" | |
| Write-Host "WinRM: $((Get-Service winrm).Status)" | |
| Write-Host "`nYou can close this window now." | |
| pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment