Use SSH & X11 forwarding on Windows

From IIHE Wiki
Jump to navigationJump to search

This page explain the procedure to enable X11 forwarding with SSH on Windows 10 & 11 using Powershell or WSL.

Powershell

PowerShell is a task automation and configuration management program from Microsoft, consisting of a command-line shell and the associated scripting language.
Since version 5.1 Powershell includes open-ssh utility allowing user to use it to connect to SSH without the need of a third party software.


Prerequities

  • A device running at least Windows Server 2019,Windows 10 (build 1809) or later.
  • PowerShell 5.1 or later.


Creating SSH keypair

Start Powershell using shortcut windows key + X, then type the following command to create your key :

ssh-keygen -t ecdsa

Follow the steps to create your ECDSA SSH keypair.

Once the key are generated you need to install Xming

Installing Xming

Get the installer from this page, then install it.

Note that you can install Xming using Chocolatey :

choco install xming -y

Ensure Xming is started before continuing.

Enabling x11 forwarding

Start Powershell and paste the following command :

$env:DISPLAY= 'localhost:0.0'

(you need to type this command each time before using x11 forwarding.)

Now connect to SSH server using -X argument :

ssh username@hostname -XY

X11 forwarding is now enabled on Powershell.