---
title: "PSRemoting for Linux and Windows: How-To Guide"
description: "Enable PSRemoting for Linux and Windows by setting up PowerShell and OpenSSH on both operating systems. Enhance your IT skills today!"
canonical: "https://adamtheautomator.com/psremoting-linux/"
---

# PSRemoting for Linux and Windows: How-To Guide

> Enable PSRemoting for Linux and Windows by setting up PowerShell and OpenSSH on both operating systems. Enhance your IT skills today!

Source: https://adamtheautomator.com/psremoting-linux/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![PSRemoting for Linux and Windows: How-To Guide](https://adamtheautomator.com/wp-content/uploads/2021/01/How-to-Set-up-PSRemoting-with-Windows-and-Linux.jpg)

# PSRemoting for Linux and Windows: How-To Guide

[![](https://secure.gravatar.com/avatar/592cc421b96f8a3f79f030a608d24047fcc0ec05ba59b5b9110af4804a6774b8?s=192&d=mm&r=g)Tyler Muir](https://adamtheautomator.com/author/tyler/)26 January 20217 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[PowerShell](/tag/powershell/)

Table of Contents

*   [Prerequisites](#h-prerequisites)
*   [Setting up Windows (Client) for PSRemoting over SSH](#h-setting-up-windows-client-for-psremoting-over-ssh)
*   [Installing PowerShell 7+](#h-installing-powershell-7)
*   [Installing OpenSSH](#h-installing-openssh)
*   [Starting up the SSH Server](#h-starting-up-the-ssh-server)
*   [Configuring the OpenSSH Configuration](#h-configuring-the-openssh-configuration)
*   [Setting up Linux (Server) for PSRemoting over SSH](#h-setting-up-linux-server-for-psremoting-over-ssh)
*   [Installing PowerShell 7+](#h-installing-powershell-7-1)
*   [Configuring OpenSSH](#h-configuring-openssh)
*   [Connecting to/from Windows/Linux with Password Authentication](#h-connecting-to-from-windows-linux-with-password-authentication)
*   [Connection Commands](#h-connection-commands)
*   [Setting up Public Key-Based Authentication](#h-setting-up-public-key-based-authentication)
*   [Generating Public/Private Keys](#h-generating-public-private-keys)
*   [Connecting to/from Windows/Linux with Public Key Authentication](#h-connecting-to-from-windows-linux-with-public-key-authentication)

One of the great things about how PowerShell has changed over the last few years is that it is adopting many ways to interact with non-Windows machines. One of these changes was to support PSRemoting over SSH. PSRemoting over SSH also means having PSRemoting Linux!

Not a reader? Watch this related video tutorial!

**_Not seeing the video? Make sure your ad blocker is disabled._**

While setting up PSRemoting to work with SSH and Linux does take a little setup to get working, this allows you to use PowerShell to interact with Linux machines natively.

In this tutorial, you’re going to learn how to set up a Windows client to connect to a Linux computer (CentOS) using PSRemoting over SSH and vice versa. You’ll learn how to authenticate using both a password _and_ using a certificate.

**_Related: [PowerShell Remoting: The Ultimate Guide](https://adamtheautomator.com/psremoting/)_**

## Prerequisites

This tutorial will be walkthrough. If you’d like to follow along, please be sure you have the following ahead of time:

*   A Windows 10 build 1809 or greater machine. The tutorial will use Windows Server 2019 Standard as the remote server.
*   [_A Linux machine that supports PowerShell 7_](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-linux?view=powershell-7.1). The tutorial will use CentOS 8.
*   Sudo rights on the Linux machine and local administrator rights on the Windows machine. After the initial setup, some of the rights can be revoked.

## Setting up Windows (Client) for PSRemoting over SSH

First up, you need to configure the PSRemoting client (PowerShell) on your Windows client. To do that, you’ll need to set up and configure both PowerShell 7+ and OpenSSH.

### Installing PowerShell 7+

First, install PowerShell 7+. This tutorial will not cover how to do this. To learn how, check out the link below.

### Installing OpenSSH

You will also need to install OpenSSH. OpenSSH is the package that PSRemoting will use to connect to the remote Linux computer. You can install OpenSSH via PowerShell using the `Get-WindowsCapability` cmdlet as shown below.

Depending on if you’re intending your Windows host to be a client and/or a server depends on what Windows feature you should install. If you connecting _from_ the Windows Server to Linux, you only need the OpenSSH client. If you are connecting from Linux _to_ the Windows Server, you only need the OpenSSH server.

The command below finds all of the Windows features with a name starting with _OpenSSH_ and installs them so it will install both the client and the server.

```powershell
Get-WindowsCapability -Online | Where-Object {$_.Name -like 'OpenSSH*'} | Add-WindowsCapability -Online
```

> _If you want to only install the client, change the filter in the `Where-Object` script block to `OpenSSH.Client*` and for the server the filter should be `OpenSSH.Server*`._

**_Related: [Getting Started using SSH and PowerShell](https://adamtheautomator.com/powershell-ssh/)_**

### Starting up the SSH Server

Once OpenSSH installs, it will open the Windows firewall on port 22, but it will not start the OpenSSH server service to listen on the port. To bring up the OpenSSH server on Windows Server, run the following PowerShell command to start the OpenSSH server and set the service to start on bootup.

```powershell
Start-Service sshd
Set-Service sshd -StartupType Automatic
```

### Configuring the OpenSSH Configuration

The next step is to modify the [_sshd\_config daemon configuration file_](https://linux.die.net/man/5/sshd_config). Inside this file, you must first confirm password authentication is enabled and also [_add the PowerShell subsystem_](https://adamtheautomator.com/powershell-ssh/).

> _This part of the tutorial is setting up the easiest method using passwords. You’ll learn how to set up SSH authentication using certificates later on in this tutorial._

1.  Open up the configuration file in your favorite text editor at _C:\\ProgramData\\ssh\\sshd\_config_.

2\. Confirm Password authentication is enabled where either the PasswordAuthentication line is commented out with a `#` at the beginning or it is set to `yes`.

![Password Authentication](https://adamtheautomator.com/wp-content/uploads/2021/01/Password_Auth-1.png)

Password Authentication

3\. Add the PowerShell subsystem. For PowerShell 7, add the line: `Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo`.

*   The `-sshs` option is used to allow PowerShell 7 to run within SSH as a subsystem.
*   The `-NoLogo` option makes PowerShell hide the copyright info when started which ensures there are not unexpected output when starting the SSH session.

4\. Save and close the config file.

5\. Restart the sshd Windows service. You can do so with PowerShell by running `Restart-Service sshd`.

You should now have everything you need configured to connect _from_ (client) and _to_ (server) this Windows Server using PSRemoting over SSH.

## Setting up Linux (Server) for PSRemoting over SSH

Next up is Linux with a similar set up; installing PowerShell and configuring OpenSSH.

> _Note that since we are using CentOS, some of the commands may be different if you are using a different distribution._

### Installing PowerShell 7+

First, install PowerShell 7. This tutorial will not cover how to do this. Instead, be sure to check out the following link.

**_Related: [How to Download and Install PowerShell 7 on Windows, macOS and Linux](https://adamtheautomator.com/powershell-7-upgrade/)_**

### Configuring OpenSSH

Like Windows Server, you’ll need OpenSSH. Unlike Windows though, OpenSSH is probably already installed. For this tutorial running CentOS 8, the Linux machine already has both the client and server installed by default but you can check using the below command:

```powershell
rpm -qa openssh*
```

If the client and server are installed you should get something similar to the output below.

![Configuring OpenSSH](https://adamtheautomator.com/wp-content/uploads/2021/01/Rpm_Openssh.png)

Configuring OpenSSH

Configure the SSH configuration file by:

1.  Opening the sshd\_config file by running `sudo vi /etc/ssh/sshd_config`.

2\. Adding the PowerShell subsystem just like on Windows Server adding the below line to the configuration file.

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

3\. Exiting vi and save the file.

4\. Restarting the ssh daemon to apply the changes by running `sudo systemctl restart sshd`.

> _By default Password and PublicKey authentication will be enabled in most instances including CentOS 8. No need to add those here._

## Connecting to/from Windows/Linux with Password Authentication

Once you’ve set up everything on both the Linux and Windows machines, it’s time to put that work you did to good use. Let’s now try to connect from Windows to Linux and vice versa using password authentication.

> _Password-based authentication looks and feels familiar to using SSH with a username and password._

### Connection Commands

To test out connecting with PSRemoting over SSH from Windows to Linux or from Linux to Windows, let’s use both an “ad-hoc” session using the `Invoke-Command` cmdlet and also a persistent session using `New-PSSession`.

**_Related: [Invoke-Command: The Best Way to Run Remote Code](https://adamtheautomator.com/invoke-command/)_**

Test out the PSRemoting connection using `Invoke-Command` by:

1.  Opening up your PowerShell 7 console.

2\. Setting parameters for the `Invoke-Command` cmdlet. In this case, the parameters below will connect to a computer called _SRV1_ using a local user account on SRV1 called _User_.

```powershell
$SessionParams = @{
     HostName = SRV1
     UserName = user
     SSHTransport = $true
 }
```

3\. Running `Invoke-Command` by splatting the parameters above and running a command (in this case [`Get-Process`](https://adamtheautomator.com/powershell-get-process/ "Get-Process") inside of a scriptblock.

**_Related: [PowerShell Splatting: What is it and How Does it Work?](https://adamtheautomator.com/powershell-splatting/)_**

```powershell
Invoke-Command @SessionParams -ScriptBlock {Get-Process}
```

You should then see a list of all running processes on the _SRV1_ computer.

You can also establish a persistent connection that allows you to connect to and from and interactively run commands by:

1.  Providing the parameters above and passing them to the `New-PSSession` cmdlet.

2\. Connecting to that session interactively using the `Enter-PSSession` cmdlet.

```powershell
Create a persistent session
 $session = New-PSSession @SessionParams
 Connect interactively
 Enter-PSSession -Session $session
```

3\. After running the `Enter-PSSession` command from above you would be prompted for the password for the user. After you authenticated, you would be connected to the other machine within PowerShell.

Notice none of the commands above required the common `Credential` parameter to provide a username and password to connect. Instead, we used the `SSHTransport` parameter. SSH does not use the same authentication process that Windows uses to go from one Windows computer to another so it cannot interpret PSCredential objects.

**_Related: [Using the PowerShell `Get-Credential` cmdlet and all things credentials.](https://adamtheautomator.com/powershell-get-credential/)_**

> _Using this approach, you can also leverage [disconnected sessions](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_remote_disconnected_sessions?view=powershell-7.1)._

## Setting up Public Key-Based Authentication

While password-based authentication is easy to set up and straightforward to use, it has two issues.

*   There is no way to authenticate without someone manually running the commands securely.
*   You are sending a password across the network.

While the password, in this case, is encrypted within the SSH connection, the server receives the password in plaintext. If the server is in some way compromised, it could become a security issue.

### Generating Public/Private Keys

When using public-key authentication of any kind, you must first generate a public key from the client. This requirement applies to both Linux and Windows.

On either the Linux or Windows Server machine:

1.  Run `ssh-keygen` to generate the key pair.

> _If you’re running `ssh-keygen` on Linux, know that it will generate an RSA key pair by default. Many new Linux operating systems will not allow RSA key pairs to be used for authentication by default. To correct this use `ssh-keygen -t ed25519`._

2\. You will be prompted for a path to store the private key and a passphrase to encrypt the private key will. In the case you want not to have to provide a password during authentication, you can leave the passphrase blank.

3\. _Windows Only:_ Run the below commands from PowerShell where `<ProfilePath>` is the path to your profile (probably _C:\\Users\\UserName_).

```powershell
Set-Service ssh-agent -StartupType Automatic
 Start-Service ssh-agent
 ssh-add .ssh\id_ed25519
 Remove-Item ~.ssh\id_ed25519
```

> _Windows’ implementation of OpenSSH has an ssh-agent service that allows you to store private keys within the Windows Security Context of the user you are logged in. This will enable you to import your SSH private key to the ssh-agent and then delete the key from the file system to secure it further._

4\. Now copy the public key generated (_<user home directory>\\.ssh\\id\_ed25519.pub_) to the server you are going to connect to. Windows does not provide a tool to do this copy so it can be completed with SCP. Run the below command to copy the public key to the Linux machine.

```powershell
scp C:\Users\Username.ssh\id_ed25519.pub username@ServerB:~/.ssh/authorized_keys
```

To copy from Linux to Windows:

```powershell
scp ~/.ssh/id_ed25519.pub administrator@ServerA:.ssh/authorized_keys
```

5\. Enter the password of the logged-in user. Once entered, PowerShell/Bash will copy the key and you will be disconnected from the remote machine.

## Connecting to/from Windows/Linux with Public Key Authentication

Once you’ve set up the public and private keys, connecting to/from both Windows and Linux should be easy. It’s nearly identical to password-based authentication.

To connect with a public key on Windows, use the identical commands as shown in **_Connection Commands_** above. You’ll only notice one difference; you will not get prompted for credentials.

Below is an example of connecting from Linux to Windows using the `-v` switch to see what’s happening during the connection.

![Example of connecting from Linux to Windows using the -v switch](https://adamtheautomator.com/wp-content/uploads/2021/01/Cert_SSH.png)

Example of connecting from Linux to Windows using the `-v` switch

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpsremoting-linux%2F&text=PSRemoting%20for%20Linux%20and%20Windows%3A%20How-To%20Guide)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpsremoting-linux%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpsremoting-linux%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

![](https://adamtheautomator.com/wp-content/uploads/2025/10/image_2025-10-24_095322075.png)

### [Migrating from PowerShell 6 to 7.5: Breaking Changes/New Features](/migrating-powershell-6-to-7-5/)

Migrate from PowerShell Core 6 to 7.5: breaking changes, features, and testing tips.

![](https://adamtheautomator.com/wp-content/uploads/2025/06/featured-image-6.png)

### [How to Add Timeouts to Pester Tests with PowerShell Runspaces](/pester-test-timeout-runspaces/)

Prevent Pester tests from hanging indefinitely using PowerShell runspaces. Learn to handle variable scoping, module loading, TestDrive access, and stream capture challenges with timeout protection.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
