PowerShell Remoting
has various benefits. It started with Windows when Windows administrators use to work remotely work with tons of windows machine over WinRM
protocol. With Automation and Unix distribution spreading across the world and require by every single IT engineer, PowerShell introduced PSRemoting over SSH
in PowerShell 7
to connect Windows
to Linux
and Linux
to Windows
remotely .
In this tutorial we will learn how to setup PS Remoting on windows machine and on Linux machine using PS remoting over SSH ( PowerShell 7
supported) . Finally we will connect both Windows to Linux and Linux to Windows machine. Lets get started.
Table of Content
- What is PSRemoting or PowerShell Remoting Over WinRM?
- What is PSRemoting or PowerShell Remoting Over SSH?
- Prerequisites
- Step by step set up SSH remoting on Windows
- Step by step set up SSH remoting on Ubuntu
- Test the OpenSSH connectivity from Windows machine to Linux using PSRemoting
- Test the OpenSSH connectivity from Linux to Windows machine using PSRemoting
- Conclusion
What is PSRemoting or PowerShell Remoting?
PowerShell Remoting
is a feature of PowerShell. With PowerShell Remoting you can connect with a single or tons of servers at a single time.

WS-Management
or Web services management
or WS-Man
provides a common way for systems to access and exchange management information across the IT infrastructure.

Microsoft implemented WS-Management
or Web services management
or WS-Man
in WinRM
that is Windows Remote Management that allows hardware and operating systems, from different vendors to connect to each other. For WinRM to obtain data from remote computers, you must configure a WinRM listener. WinRM listener can work on both HTTP or HTTPS Protocols.

When PowerShell Remoting takes place between two servers that is one server try to run commands remotely on other server, the source server connects to destination server on WinRM Listener. To configure PSRemoting on local machine or remote machine please visit the link
What is PSRemoting or PowerShell Remoting Over SSH?
Microsoft introduced PowerShell 7 Remoting over SSH, which allows true multiplatform PowerShell remoting between Linux, macOS, and Windows. PowerShell SSH Remoting creates a PowerShell host process on the target machine as an SSH subsystem. Normally, Windows PowerShell remoting uses WinRM for connection negotiation and data transport. However, WinRM is only available on Windows-based machines. That means Linux machines can connect with windows or windows can connect to Windows over WinRM but Windows cannot connect to Linux.
With PowerShell 7 Remoting over SSH Now its possible to remote between Linux, macOS, and Windows.

Prerequisites
- Microsoft Windows Server 2019 standard . This machine should also have PowerShell 7 installed. If you don’t have PowerShell installed please follow here to install.
- Make sure you have local account setup in Windows server 2019. We will be using “automate” user.
- Make sure you set the password for ubuntu user on ubuntu machine or if you have it then ignore.
- Ubuntu machine with PowerShell 7 installed.
Step by step set up SSH remoting on Windows
Here we will discuss about how to setup SSH remoting on Windows
Machine and run the PSRemoting commands.
- Assuming you are on Windows 2019 standard machine with PowerShell 7 installed. Lets verify it once.

- Before we setup SSH on windows machine & if you try to make a SSH session with Linux machine you will received an error message like this.

- Next step is to install Open SSH client and server on Windows 2019 standard server. Lets use the PowerShell utility
Add-WindowsCapabillity
and run the commands.

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0


- Once Open SSH is installed successfully , we need to start the OpenSSH Services.
Start-Service sshd
Set-Service sshd -StartupType Automatic

- Now, Edit the OpenSSH configuration
sshd_config
located in C:\Windows\System32\OpenSSH or you can find it in C:\ProgramData\ssh\sshd_config by adding Subsystem for PowerShell.
Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo -NoProfile

- Also make sure OpenSSH configuration file
sshd_config
hasPasswordAuthentication
set to yes
- Restart the service
Restart-Service sshd
- SSH remoting is now properly set on Windows Machine
Step by step set up SSH remoting on Ubuntu
Previously we configured SSH remoting on Windows Machine , now we need to perform similar steps in ubuntu machines with various commands.
- PowerShell 7 must be installed on ubuntu machine
- Install OpenSSH client and server on ubuntu machine
sudo apt install openssh-client
sudo apt install openssh-server

- Similarly Edit the Sshd_config file in ubuntu machine
vi /etc/ssh/sshd_config
- Paste the below content (Add the Subsystem for PowerShell) and make sure
PasswordAuthentication
set to yes
Subsystem powershell /usr/bin/pwsh -sshs -NoLogo -NoProfile

- Restart the service
sudo service sshd restart
Test the OpenSSH connectivity from Windows machine to Linux using PSRemoting
Here now we are set with windows and ubuntu SSH remoting steps , now lets verify the SSH connectivity between from windows to ubuntu machine
Verification Method 1
- Create a session and then enter into session and run commands from windows PowerShell to Linux PowerShell
New-PSSession -Hostname 54.221.35.44 -UserName ubuntu # Windows to Linux Create Session
Enter-PSSession -Hostname 54.221.35.44 -UserName ubuntu # Windows to Linux Enter Session

Verification Method 2
- Create the session and then test the connectivity from Windows machine to Linux using
Invoke-Command
command
$SessionParams = @{
HostName = "54.221.35.44"
UserName = "ubuntu"
SSHTransport = $true
}
Invoke-Command @SessionParams -ScriptBlock {Get-Process}

Test the OpenSSH connectivity from Linux to Windows machine using PSRemoting
Lets verify the SSH connectivity between from ubuntu machine to windows Machine.
- Open PowerShell on ubuntu machine with following command
pwsh
- Although you are on ubuntu machine lets verify the ubuntu version [Optional Step]
- Now SSH into Windows machine using following command
ssh automate@3.143.233.234

- Here we go , You can clearly see that we are have SSH into Windows machine successfully

Conclusion
PowerShell Remoting has various benefits. It started with Windows when Windows administrators use to work remotely work with tons of windows machine over WinRM protocol. With Automation and Unix distribution spreading across the world and require by every single IT engineer. To resolve problem of connecting windows to Linux and Linux to windows PowerShell introduced PSRemoting over SSH to connect Windows to Linux and Linux to Windows remotely with easy setups .
Hope you find this tutorial helpful. If you like please share it with your friends.