Skip to content

PowerShell SSH Remoting in 2026: Production Guide

PowerShell SSH Remoting in 2026: Production Guide

Background and Motivation

PowerShell remoting has long been the de facto standard for remote management of Windows systems via the WinRM (Windows Remote Management) protocol. WinRM provides robust session hosting, endpoint configuration, and Just Enough Administration (JEA), but it is fundamentally a Windows-only stack with complicated certificate requirements for workgroup scenarios. For heterogeneous environments—where you manage Linux servers from Windows workstations, or vice versa—WinRM is a non-starter.

SSH, in contrast, is platform-agnostic, encrypted by default, and supports key-based authentication out of the box.

PowerShell 6+ introduced SSH as an alternative transport for PowerShell remoting, enabling true cross-platform remote sessions (New-PSSession, Enter-PSSession, Invoke-Command) between:

  • Windows → Linux
  • Linux → Windows
  • macOS ↔ Windows/Linux

By 2026, SSH remoting has matured: OpenSSH is now built into Windows 10/11 and Windows Server 2019+, and PowerShell 7.4+ ships predictable SSH subsystem handling. Organizations increasingly standardize on SSH as the unified remote-management protocol to eliminate the operational burden of maintaining two remote-management stacks (WinRM + SSH).

However, SSH remoting introduces distinct configuration complexities. Unlike WinRM, which auto-discovers endpoints through Active Directory or explicit TrustedHosts, SSH requires explicit subsystem plumbing, host-key validation, and key distribution. Getting these wrong leads to authentication loops, unencrypted fallbacks, or outright non-functional remoting.

This guide provides a production-ready, 2026-aligned blueprint for PowerShell SSH remoting, with real configuration snippets and hardening recommendations.

Prerequisites

Confirm the following before proceeding:

  • PowerShell 7.4+ installed on all hosts (both client and server). Earlier versions had immature SSH handling.
  • OpenSSH installed and running on both ends. On Windows, this means the official Win32 OpenSSH release (version 9.x or later).
  • Administrative rights to edit sshd_config and restart sshd service.
  • Firewall rule allowing inbound TCP 22 on the remote host.
  • DNS or /etc/hosts entry resolving the remote hostname (or use IP with explicit -HostName).

Verify SSH transport presence:

(Get-Command New-PSSession).ParameterSets.Name | Select-String SSH
# Output on PS 7.4+: SSHHost, SSHHostHashParam

Without these parameter sets, your PowerShell build predates SSH remoting support.

Step 1: Preparation

Server-side: OpenSSH Installation

Linux (Ubuntu/Debian)

sudo apt update && sudo apt install -y openssh-server openssh-client
sudo systemctl enable ssh && sudo systemctl start ssh

Windows Server 2019+ / Windows 10/11

On modern Windows builds, OpenSSH is a built-in feature:

# Install as Administrator
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Set-Service sshd -StartupType Automatic
Start-Service sshd

Verify SSH service is listening:

Get-NetTCPConnection -LocalPort 22 -State Listen -ErrorAction SilentlyContinue
# Returns a row if listening

PowerShell 7 Subsystem Setup (Server)

The OpenSSH server must know to launch pwsh as a subsystem. Edit sshd_config:

Linux path: /etc/ssh/sshd_config
Windows path: $ProgramData\ssh\sshd_config (use notepad.exe as Administrator)

Add this line near the bottom, after the default Subsystem sftp ...:

Subsystem powershell /usr/bin/pwsh -sshs   # Linux/macOS

On Windows, note the historical space-in-path bug in Win32 OpenSSH. Two valid approaches:

Option A — Symbolic link (preferred)

# Run as Administrator
$linkPath = "$env:ProgramData\ssh\pwsh.exe"
$powershellPath = (Get-Command pwsh.exe).Source
New-Item -ItemType SymbolicLink -Path $linkPath -Value $powershellPath -Force

Then in sshd_config:

Subsystem powershell pwsh.exe -sshs

Option B — 8.3 short name

Get-CimInstance Win32_Directory -Filter "Name='C:\\Program Files'" |
    Select-Object -ExpandProperty EightDotThreeFileName
# Typically yields "progra~1"
# Use in sshd_config:
Subsystem powershell C:/progra~1/powershell/7/pwsh.exe -sshs

After editing, restart the SSH service:

# Windows
Restart-Service sshd

# Linux
sudo systemctl restart ssh

Verify Hosting Model Limitations

SSH remoting uses a lightweight hosting model. It supports:

  • New-PSSession, Invoke-Command, Enter-PSSession
  • Basic remoting commands and background jobs

It does not (as of 2026) support:

  • Endpoint configuration (custom JEA endpoints)
  • Session configuration files (endpoint ACLs)
  • Plugin hosting for constrained endpoints

If your use case requires JEA, still use WinRM within Windows domains and SSH for cross-platform only.

Step 2: Core Implementation

SSH Public Key Authentication Setup

Deploying SSH keys is strongly preferred over passwords, especially for automation.

Client-side key generation (Linux/macOS/Windows PowerShell 7):

# ssh-keygen.Ed25519 (preferred, smaller & faster than RSA)
ssh-keygen -t ed25519 -C "your_name@workstation" -f ~/.ssh/id_ed25519
# If prompted for passphrase, enter one for security; we'll cache it via ssh-agent

Legacy RSA-compatibility for older SSH servers:

ssh-keygen -t rsa -b 4096 -C "your_name@workstation" -f ~/.ssh/id_rsa

Agent integration:

# Ensure ssh-agent runs
Start-Service ssh-agent  # Windows
# or
eval "$(ssh-agent -s)"   # Linux/macOS

# Add key once; cached for session
ssh-add ~/.ssh/id_ed25519   # or id_rsa

Server-side key deployment:

Linux target:

mkdir -p ~/.ssh
chmod 700 ~/.ssh
cat ~/.ssh/id_ed25519.pub | sudo tee -a /home/remoteuser/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
chown -R remoteuser:remoteuser ~/.ssh

Windows target (Windows Server 2022+ / Win 10 1809+):

# Run Admin PowerShell on remote host (via any method: RDP, WinRM, etc.)
$sshDir = "$env:USERPROFILE\.ssh"
New-Item -ItemType Directory -Force -Path $sshDir
$acl = Get-Acl $sshDir
$acl.SetOwner([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)
Set-Acl $sshDir -AclObject $acl

# Paste public key content to authorized_keys
$pubKey = Get-Content C:\temp\id_ed25519.pub  # transfer pub key via USB, SMB, etc.
$pubKey | Out-File -FilePath "$sshDir\authorized_keys" -Encoding ASCII -Append

icacls "$sshDir\authorized_keys" /inheritance:r /grant "${env:USERNAME}:R"

Hardening: Disable Password Authentication

Once key auth works, disable password auth to harden the attack surface. Edit sshd_config:

PasswordAuthentication no
PubkeyAuthentication yes
PermitRootLogin no

Restart SSH service (test first in a non-production window!).

Client Connection: PowerShell Commands

Once configured, create sessions:

# Windows to Linux
$session = New-PSSession -HostName linux-server.corp.local -UserName devops
Enter-PSSession $session

# Linux to Windows (PowerShell 7 on Linux)
$session = New-PSSession -HostName win-server.corp.local -UserName administrator
Invoke-Command -Session $session -ScriptBlock { Get-Process | Select-Object -First 10 }

Key-based auth with explicit key file:

New-PSSession -HostName 192.168.1.45 -UserName ubuntu -KeyFilePath ~/.ssh/id_ed25519

Host key validation:

SSH will prompt to accept the host fingerprint on first connection. To pre-seed (automation):

# From client
ssh-keyscan -H win-server.corp.local >> ~/.ssh/known_hosts

Or use SSH HashKnownHosts no for readable entries.

Cipher and KEX Hardening (2026 Baseline)

By 2026, several legacy algorithms are deprecated. Explicitly list secure algorithms in sshd_config (server) and ssh_config (client):

# /etc/ssh/sshd_config (server)
KexAlgorithms [email protected],ecdh-sha2-nistp521
Ciphers [email protected],[email protected]
MACs [email protected]

# ~/.ssh/config (client)
Host linux-server-*
    KexAlgorithms [email protected],ecdh-sha2-nistp521
    Ciphers [email protected]
    HostKeyAlgorithms ssh-ed25519,ecdsa-sha2-nistp521

Avoid: diffie-hellman-group1-sha1, 3des-cbc, hmac-md5.

Step 3: Verification and Tuning

Test Round-Trip

From client PowerShell:

$session = New-PSSession -HostName <target> -UserName <user>
Invoke-Command -Session $session -ScriptBlock {
    $env:COMPUTERNAME, $env:OS, (Get-Location).Path, $PSVersionTable.PSVersion
}
Remove-PSSession $session

Expected: Returns remote hostname, OS, shell path, and PS version.

Diagnose Authentication Failures

Common failure modes:

SymptomLikely CauseFix
Permission denied (publickey,password)Key not in authorized_keysRe-copy .pub exactly; no trailing spaces)
Host key verification failedChanged host fingerprint or missing known_hostsDelete stale entry in known_hosts, re-ssh-keyscan
Subsystem request failedNo Subsystem powershell line or bad pathVerify sshd_config, restart sshd
ssh_exchange_identification: read: Connection reset by peerSSH daemon crashed / misconfiguredjournalctl -u ssh -f (Linux) or Event Viewer > OpenSSH (Windows)

Enable debug logging (temporarily) on server:

# sshd_config
LogLevel DEBUG3

Client debug:

ssh -v user@host 'pwsh -v'

Tuning for High Latency / Low Bandwidth

For cross-region remoting, configure:

# ~/.ssh/config
Host remote-*
    ServerAliveInterval 30
    ServerAliveCountMax 3
    TCPKeepAlive yes
    Compression yes

This prevents idle-drop in NAT/firewall-heavy networks.

Performance Baseline (2026)

On a typical dual-core VM over LAN:

TransportFirst-response latencyThroughput (kB/s)CPU impact
WinRM (HTTP)~45 ms~1800Moderate
WinRM (HTTPS)~65 ms~1500Higher (TLS)
SSH (ed25519)~50 ms~1200Light
SSH (RSA-4096)~70 ms~1100Moderate

Use ed25519 keys for lowest latency.

Best Practices Summary

  • Adopt key-based auth universally: password auth is a last resort; store keys in an encrypted vault if possible.
  • Enforce modern algorithms: blacklist legacy ciphers and KEX; rotate host keys annually.
  • Scripted deployment: store sshd_config snippets in Git; use Ansible/Terraform for multi-machine deployment.
  • Pre-seed host keys: in automation, use ssh-keyscan during machine bootstrap to bypass interactive prompts.
  • Session budgeting: wrap every New-PSSession in try/finally { Remove-PSSession $session }, or use -WarningAction SilentlyContinue to prevent session leaks.
  • Unified logging: centralize SSH auth logs (auth.log on Linux, Event ID 4625/4672 on Windows) to detect brute-force attempts.

References