Lesson 1 of 14 · 18m
Remoting: WinRM, PSRemoting, and Real OpenSSH
Windows admin runs over WinRM on 5985/5986 or Microsoft-shipped OpenSSH on 22 — not RDP — and the admins_authorized_keys and double-hop traps decide whether it works.
How commands actually reach a Windows box
Administration on Windows is an RPC business. Two transports carry nearly all of it: WinRM — Microsoft's implementation of WS-Man, SOAP-shaped HTTP on TCP 5985, or 5986 with TLS — and, since Windows 10 1809 and Server 2019, a real OpenSSH server on TCP 22. RDP is for humans watching a screen. The MMC snap-ins are thin shells over the same COM and WMI interfaces PowerShell calls. If you are clicking, you are doing it the slow way.
The mental model to kill: "PowerShell is a scripting language." It's the management interface. Enter-PSSession -ComputerName srv01 gives you an interactive shell over WinRM. Invoke-Command -ComputerName (Get-Content servers.txt) -ScriptBlock { Get-Service wuauserv } fans one command out to the fleet in parallel — the idiom Linux people reach for pssh or Ansible for is built in, and it returns deserialized objects, not text. -ThrottleLimit 64 controls parallelism, and New-PSSession holds a persistent session you can Enter- and Invoke- against repeatedly.
Turning it on
On a domain box, one cmdlet does everything:
Enable-PSRemoting -ForceThat starts the WinRM service, creates the HTTP listener, opens the "Windows Remote Management" firewall rules, and registers the default session configurations. Test-WSMan srv01 verifies the path. winrm get winrm/config shows the whole listener and auth stack; the GPO path is Computer Configuration → Administrative Templates → Windows Components → Windows Remote Management.
Outside a domain you hit two sharp edges: the target must be in the client's TrustedHosts list (Set-Item WSMan:\localhost\Client\TrustedHosts -Value srv01 — * works and is the wrong answer for a fleet), or you configure an HTTPS listener with a real certificate (New-Item WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint <thumb> -Force). Kerberos auth only works in-domain; without it you're into NTLM-with-TrustedHosts territory, which is fine for a lab and wrong for production.
OpenSSH, the honest way
Microsoft ships OpenSSH as a Feature on Demand:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service sshd -StartupType 'Automatic'The OpenSSH-Server-In-TCP firewall rule is created for you; sshd_config lives at C:\ProgramData\ssh\sshd_config. Two traps everyone hits exactly once:
- Public-key auth for members of Administrators ignores
~\.ssh\authorized_keys. Admin keys go inC:\ProgramData\ssh\administrators_authorized_keys— a hardcoded rule in the shipped config, not a bug in yours. - The login shell defaults to
cmd.exe. SetHKLM\SOFTWARE\Microsoft\OpenSSH\DefaultShelltoC:\Program Files\PowerShell\7\pwsh.exeunless you enjoy cmd.
Which brings up the version split: powershell.exe is Windows PowerShell 5.1 — inbox, final, frozen. pwsh.exe is PowerShell 7 — the maintained cross-platform build you install separately. PowerShell 7 can remote over SSH (Enter-PSSession -HostName); 5.1 is WinRM-only. Mixed fleets should standardize on 7.
The double-hop that eats hours
Invoke-Command runs under your ticket on the remote box. But if that command reaches a second machine — mounting a UNC share, a nested remoting call — it fails, because Kerberos doesn't forward credentials by default. The fixes, in order of preference: constrained Kerberos delegation on the middle box; CredSSP (Enable-WSManCredSSP -Role Client / -Role Server), which works but ships the credential to the intermediary, so scope it deliberately; or JEA — Just Enough Administration — a constrained session configuration where helpdesk gets four commands instead of a shell.
JEA deserves ten more seconds: a .pssc session configuration plus .psrc role capabilities define an endpoint where a helpdesk account gets, say, Restart-Service and nothing else — constrained runspaces, virtual accounts, transcripts logged by default. It is the correct answer to "contractor needs to bounce one service."
This isn't exotic plumbing. Exchange on-prem has worked this way since 2010 (New-PSSession + Import-PSSession is "implicit remoting" — remote cmdlets imported into a local session), Ansible manages Windows over WinRM via pypsrp, and every WinRM logon leaves a 4624 type 3 network logon plus Microsoft-Windows-WinRM operational events — which is exactly what lateral movement looks like when an operator uses the same plumbing. Treat winrm listeners like sshd: enumerate them, scope them, watch them.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
BlueHammer: The Unpatched Windows Zero-Day That Weaponizes Microsoft Defender Against Your Own System
BlueHammer is an unpatched, publicly released Windows local privilege escalation exploit that chains Microsoft Defender's update workflow, Volume Shadow Copy, Cloud Files callbacks, and opportunistic locks to reach NT AUTHORITY\SYSTEM from a standard user account.
A Fake GTA 6 ISO Didn’t Install a Game. It Installed a Wiper.
A fake GTA 6 ISO used a believable installer error to cover remote-access malware, browser-data theft, and destructive file wiping. The “License not found” message wasn’t the crack failing. It was there so the victim would stop looking.
Running a Minecraft Network: Four JVMs, One Box, and the Settings That Lie to You
Four servers on one host means four JVMs each sizing its thread pools for a machine it does not own. The measured cost of that, the systemd ordering that guarantees nothing, and the throttle that switches itself back on when your forwarding breaks.
Building a Minecraft Network: Four Servers Pretending to Be One Place
A proxy, a lobby, an SMP and a PvP arena is four JVMs that know nothing about each other. What actually has to be shared, why your permissions don't follow players, and the two LuckPerms defaults that silently share nothing at all.