Install OpenSSH on Windows for PowerShell Core remoting via SSH
If you have been following the developments over the last year on PowerShell Core, you’ll know that the PowerShell team has been hard at work. Not only are they quickly approaching the release of the production version of PowerShell Core, but they have also been working constantly on several projects. These include Desired State Configuration, the PowerShell Visual Studio Code extension, and the topic of this article: porting OpenSSH to Windows.
SSH has long been the remoting mainstay in the Linux world. In client scenarios, PuTTY on Windows is the most common use of SSH, as it allows a Windows user to SSH into a Linux system. There are other third-party solutions providing an SSH server on Windows, but having a Microsoft team officially providing it will make it easier to adopt.
Although Windows PowerShell users are used to WinRM as their remoting protocol with PowerShell, it makes a lot of sense to enable Windows to use SSH. The ability to use SSH provides a common user experience for Linux users to connect to Windows systems remotely and vice versa. In my opinion, in the not-so-distant future, SSH will likely become the remoting protocol of choice for Windows users as well.
Installing the OpenSSH package
Currently, there are two ways to install OpenSSH on Windows documented on GitHub. I recommend using Chocolatey because it is much simpler and automates a few of the necessary tasks for you.
In PowerShell or cmd, this command will install both the client tools and server component. To install just the client tools, remove the ‑param argument. Among other tasks, it opens the proper firewall ports and sets or starts the sshd and ssh-agent services:
choco install openssh -params '"/SSHServerFeature /KeyBasedAuthenticationFeature"' –y