PowerShell Remoting over SSH to Raspberry PI OS

Image Description

Daily PowerShell #26

Linux Daily PowerShell Remoting

November 11, 2021

quote Discuss this Article

In this post, we’ll look at how to install PowerShell on Raspberry PI OS and enable remoting.

Enable SSH in Raspberry PI OS

You can enable SSH in Raspberry PI OS by creating an empty ssh file in the boot volume of the boot disk.

cd /Volumes/boot
touch ssh

Installing PowerShell

You can install PowerShell by using the following command line. This command line comes directly from the PowerShell documentation.

###################################
# Prerequisites

# Update package lists
sudo apt-get update

# Install libunwind8 and libssl1.0
# Regex is used to ensure that we do not install libssl1.0-dev, as it is a variant that is not required
sudo apt-get install '^libssl1.0.[0-9]$' libunwind8 -y

###################################
# Download and extract PowerShell

# Grab the latest tar.gz
wget https://github.com/PowerShell/PowerShell/releases/download/v7.2.0/powershell-7.2.0-linux-arm32.tar.gz

# Make folder to put powershell
mkdir ~/powershell

# Unpack the tar.gz file
tar -xvf ./powershell-7.2.0-linux-arm32.tar.gz -C ~/powershell

# Start PowerShell
~/powershell/pwsh

Enable PowerShell Remoting

Now that PowerShell is installed, you can setup the SSH server to use the PowerShell subsystem.

Open the SSH config file in nano.

sudo nano /etc/ssh/sshd_config

Next, add a new line to the file.

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

Finally, save the file by exiting with Ctrl+X then press Y and Enter.

Once the file is saved, you’ll need to restart the SSH service.

sudo systemctl restart sshd

Connecting with PowerShell

Now that remoting is configured, you can connect to your Raspberry PI from a Windows machine with the SSH transport.

Enter-PSSession -HostName raspberrypi -Username pi -SSHTransport
pi@raspberrypi's password:
[pi@raspberrypi]: PS /home/pi> gps