Many people quickly associate PowerShell with Windows. And while that makes perfect sense, since it was only available for Windows up to version 5.1.x, the introduction of PowerShell Core made it available and highly usable on other UNIX-based platforms as well. For people like me, who work with PowerShell every day and only occasionally use a Linux terminal, it is very convenient to be able to connect to Linux using the same PowerShell console. In this post, I will explain how to set this up using SSH and what we need to make it work. The ultimate goal is to manage Linux servers directly from PowerShell.

Since I primarily work with Ubuntu, all Linux commands in this article are based on Ubuntu. For other distributions, I would recommend consulting Google or other reliable sources.

Why PowerShell over SSH?

PowerShell Remoting over SSH combines the power of PowerShell with the universal availability of SSH. Especially in environments where both Windows and Linux systems are managed, it provides a modern and flexible way of working.

No WinRM Configuration Required

Traditional PowerShell Remoting on Windows relies on WinRM (Windows Remote Management). While WinRM is a powerful and mature technology, it often requires additional configuration before it can be used effectively. Depending on the environment, administrators may need to enable the WinRM service, adjust firewall rules, configure HTTPS certificates for secure communication, and make additional network or security changes in hybrid environments.

SSH removes most of that complexity. It is available by default on virtually every Linux distribution and has become increasingly common on Windows as well. Because SSH is already a familiar and widely accepted standard, getting PowerShell Remoting up and running is often much simpler.

For administrators, this translates into less configuration overhead, fewer dependencies on Windows-specific technologies, and a faster path to implementing remote management. In many cases, a Linux server that already has SSH enabled can be prepared for PowerShell Remoting in just a matter of minutes.

Works Across Platforms

One of the biggest advantages of PowerShell 7 is its true cross-platform nature. The same PowerShell experience is available on Windows, Linux, and macOS, allowing administrators to use a consistent set of tools and workflows regardless of the operating system they are working on. Whether you’re managing a Linux server from Windows, connecting from macOS, or even administering Windows systems from Linux, PowerShell provides a familiar interface and scripting language across all platforms.

Instead of maintaining separate scripts, documentation, and skill sets for each operating system, teams can standardise on PowerShell wherever possible. The result is simpler automation, more consistent operational procedures, and easier knowledge sharing across teams that support mixed Windows and Linux environments.

Secure Communication Through SSH

SSH has been the de facto standard for secure Linux administration for many years.

Encrypted Communication

All communication between the client and server is encrypted. This prevents passwords, commands, and output from being easily intercepted.

Public Key Authentication

Instead of passwords, you can use SSH keys. The benefits include:

  • No passwords in scripts.
  • Stronger authentication.
  • Ideal for automation.
  • Reduced risk of brute-force attacks.

Established Security Standards

Many organisations already allow SSH within their security policies. As a result, there is no need to build additional infrastructure around WinRM.

For network and security teams, SSH often feels more natural than WinRM because it is already part of their daily workflow.

A Consistent Management Experience for Windows and Linux

Many administrators constantly switch between PowerShell for Windows, Bash for Linux, different management portals and various remote management tools.

With PowerShell on Linux, that distinction becomes increasingly blurred. When you open a PowerShell session to a Linux server, the user experience remains almost identical. You also retain all the benefits of PowerShell:

  • Objects instead of text
  • Pipelines
  • Variables
  • Functions
  • Modules
  • Error handling

For administrators who have worked with PowerShell for years, this results in a much lower learning curve than rewriting everything in Bash.

Supports Both Enter-PSSession and Invoke-Command

PowerShell Remoting over SSH supports the same familiar remoting commands that Windows administrators have been using for years.

Summary regarding the why

PowerShell Remoting over SSH provides a modern, secure, and platform-independent way to manage Linux systems. You benefit from the familiar PowerShell experience without depending on WinRM, while leveraging the proven security of SSH. For administrators who support both Windows and Linux, it is a smart and efficient way of working that allows interactive sessions (Enter-PSSession) and large-scale automation (Invoke-Command) to be combined with ease.

What Do We Need?

On the Linux server, you need:

  • OpenSSH Server
  • PowerShell 7 or later

And on your Windows machine:

  • PowerShell 7 or later (verify with $PSVersionTable.PSVersion)
  • OpenSSH Client

Step 1: Install PowerShell on Linux

In a terminal on the Linux server, run the following commands:

sudo apt update
sudo apt install powershell

To verify that the installation was successful, run pwsh. This launches the PowerShell console. You should now see a PowerShell prompt.

PowerShell 7.5.0
PS /home/jos>

Step 2: Configure SSH for PowerShell Remoting

Although PowerShell is now installed on the machine, SSH will not automatically connect you to PowerShell when a session is established. A small amount of additional configuration is required.

Check where PowerShell is installed:

which pwsh

Example output:

/usr/bin/pwsh

-or-

/opt/microsoft/powershell/7/pwsh

Open the SSH configuration file:

sudo nano /etc/ssh/sshd_config

Add the following line at the bottom of the file and replace the path if necessary with the one you found earlier:

Subsystem powershell /usr/bin/pwsh -sshs -NoLogo -NoProfile

Alright, let’s take a quick pause here. This line is often copied without much explanation, but quite a lot is happening behind the scenes.

  • Subsystem – Tells OpenSSH that an additional protocol handler is available alongside the default shell.
  • powershell – The name of the subsystem. PowerShell uses this name when you execute remoting commands. PowerShell Remoting essentially tells SSH: “Start the ‘powershell’ subsystem.”
  • /usr/bin/pwsh – The PowerShell executable. SSH launches PowerShell instead of Bash.
  • -sshs – This parameter is critical. Normally, pwsh starts an interactive console. For remoting, PowerShell must run in a dedicated SSH remoting mode.
  • -NoLogo – Suppresses the startup banner. This prevents unnecessary output when establishing the remoting session.
  • -NoProfile – Prevents user profiles from loading. Without this, the remoting session can fail because unexpected text may be sent back to the client.

Save the configuration and restart SSH:

sudo systemctl restart ssh

or

sudo systemctl restart sshd

Step 3: Test Standard SSH Access

Before using PowerShell Remoting, first verify that SSH connectivity works from your Windows machine.

ssh jos@linux01

If you can log in successfully, you’re ready for the next step.

Step 4: Create an Interactive PowerShell Session

From PowerShell 7 on Windows:

Enter-PSSession -HostName linux01.contoso.local -UserName jos

Your prompt will change to something similar to:

[jos@linux01]: PS /home/jos>

From this point onward, all PowerShell commands are executed on the Linux server.

Step 5: Execute Individual Commands

For automation tasks, Invoke-Command is often more convenient.

Invoke-Command -HostName linux01 -UserName jos -ScriptBlock {
    Get-Date
}

Working with SSH Keys

For automation purposes, you probably don’t want to enter a password every time. Fortunately, this is easy to set up. On the Windows machine, generate an SSH key pair. ed25519 is the algorithm used to create the key.

ssh-keygen -t ed25519

Copy the public key to Linux:

ssh-copy-id jos@linux01

Or, if you prefer to do it manually:

type $env:USERPROFILE\.ssh\id_ed25519.pub

And add the contents to:

~/.ssh/authorized_keys

PowerShell Remoting should now work without requiring a password.

Creating a Persistent PSSession

# Create a session
$Session = New-PSSession -HostName linux01 -UserName jos

# Test if the session was created
Get-PSSession

# Test if the session works
Invoke-Command -Session $Session -ScriptBlock {
    hostname
}

# Remove the session
Remove-PSSession $Session

Practical Example: Checking Linux Updates

$Session = New-PSSession -HostName linux01 -UserName jos

Invoke-Command -Session $Session -ScriptBlock {
    apt list --upgradable
}

Remove-PSSession $Session

Common Errors

Connection Refused

Check whether SSH is running:

systemctl status ssh

Subsystem Request Failed

Verify that the output of which pwsh matches the path specified in:

Subsystem powershell /usr/bin/pwsh -sshs -NoLogo -NoProfile

File:

/etc/ssh/sshd_config

Enter-PSSession Does Not Work

Verify that you are using PowerShell 7. Running:

$PSVersionTable.PSEdition

should return:

Core

Windows PowerShell 5.1 does not support SSH remoting.

Conclusion

PowerShell Remoting over SSH combines the best of two worlds: the power of Linux and the familiar PowerShell management experience. With only a small amount of configuration on the Linux server, you can open interactive sessions, execute scripts, and manage Linux systems from the same PowerShell console you already use for Windows.

For administrators who manage both Windows and Linux, this is one of the most underrated features of PowerShell 7. It makes cross-platform administration simpler, more consistent, and easier to automate than ever before.

Leave a Reply

Your email address will not be published. Required fields are marked *