[Tutorial] Connect SSH Using Windows PowerShell

PowerShell Remote SSH Techhyme

PowerShell Remoting allows you to execute PowerShell commands or scripts on remote computers. It enables you to manage and administer remote systems from a single computer.

PowerShell Remoting provides various useful features like background jobs, remote script execution, and remote module management. You can learn more about these features and additional remoting cmdlets in the official PowerShell documentation.

Also Read: PowerShell Books

Remember, PowerShell Remoting requires administrative privileges and proper network connectivity between the local and remote computers. Ensure that you have the necessary permissions and firewall rules configured to establish remote connections.

Assuming you are on Windows 10 with PowerShell 7 installed. Lets verify it once.

Command: Get-Host | Select-Object Version

Windows powershell SSH Linux Techhyme

As you can see that, the current PowerShell version is 5 but for PowerShell Remoting, your minimum version should be 7 at least.

So download the PowerShell 7 version from GitHub repository.

Windows powershell SSH Linux Techhyme

Extract the folder

Windows powershell SSH Linux Techhyme

And run pwsh.exe file by double clicking on it.

Windows powershell SSH Linux Techhyme

Now verify the version of PowerShell by running the following command:

Command: Get-Host | Select-Object Version

Windows powershell SSH Linux Techhyme

To get a list of all available commands, you can run:

Command: Get-Command

Windows powershell SSH Linux Techhyme


Windows powershell SSH Linux Techhyme

To make a connection from Windows machine to Linux machine, the command is:

Command: New-PSSession -Hostname -UserName techhyme

Windows powershell SSH Linux Techhyme

If you try to make a SSH session with Linux machine you may receive an error message like this.

New-PSSession: [] The SSH Client session has ended with error message: The SSH transport process has abruptly terminated causing this remote session to break.

Next step is to install Open SSH client and server on Windows 10.

Lets use the PowerShell utility Add-WindowsCapabillity and run the commands.

Command: Add-WindowsCapability -Online -Name OpenSSH.Client~~~~
Command: Add-WindowsCapability -Online -Name OpenSSH.Server~~~~

Windows powershell SSH Linux Techhyme

Once OpenSSH is installed successfully, you need to start the OpenSSH Services by running the following command:

Command: Start-Service sshd

Windows powershell SSH Linux Techhyme

If you want to start the “sshd” service automatically when the computer boots up, then the command is:

Command: Set-Service sshd -StartupType Automatic

Windows powershell SSH Linux Techhyme

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 pwsh.exe -sshs -NoLogo -NoProfile

Windows powershell SSH Linux Techhyme

Also make sure OpenSSH configuration file sshd_config has PasswordAuthentication set to yes.

Restart the service by using:

Command: Get-Service -Name sshd | Restart-Service

Windows powershell SSH Linux Techhyme

SSH remoting is now properly set on your Windows Machine.

Related Posts

Adding Users in Windows and Linux: A Step-by-Step Guide

Adding users to an operating system is a fundamental administrative task that allows individuals to access and utilize a computer system. Both Windows and Linux offer methods…

File Permissions Linux Techhyme

Understanding Common File Permissions in Linux

File permissions are a fundamental aspect of file management in Unix-based operating systems like Linux. They play a crucial role in determining who can access, modify, or…

Active Connections Kali Linux Techhyme

How To Check Active Connections in Kali Linux

Kali Linux, known for its prowess in cybersecurity and ethical hacking, provides a powerful command-line tool called `netstat` for monitoring active network connections. This tool is indispensable…

Kali linux system information commands techhyme

Top 11 System Information Commands in Kali Linux

In the realm of ethical hacking and penetration testing, the post-exploitation phase is a critical juncture where an attacker seeks to establish and maintain control over a…

Linux System Key Components Techhyme

7 Major Key Components That Make Up A Linux System

Linux, an open-source operating system, has become one of the most widely used platforms due to its stability, security, and flexibility. It is comprised of various components…

File Finding Commands Linux Techhyme

Top 4 File Finding Commands in Linux

In the vast world of Linux, one of the most common tasks is finding files and directories scattered throughout the file system. Fortunately, Linux provides several powerful…

Leave a Reply