02-05-2021



OpenSSH is the premier connectivity tool for remote login with the SSH protocol. It encrypts all traffic to eliminate eavesdropping, connection hijacking, and other attacks. In addition, OpenSSH provides a large suite of secure tunneling capabilities, several authentication methods, and sophisticated configuration options.

Goals

  • Using Git Bash, follow the steps for generating an SSH key adding it to the ssh-agent. Using Git Bash, follow the steps for adding the SSH key to your GitHub account. To verify that everything is working correctly, consider making a new private repository on GitHub and cloning its SSH link to your computer.
  • OpenSSH is the open-source version of the Secure Shell (SSH) tools used by administrators of Linux and other non-Windows for cross-platform management of remote systems. OpenSSH has been added to Windows as of autumn 2018, and is included in Windows 10 and Windows Server 2019.

We want to install OpenSSH on a Windows Server 2019, so we can remote access it with ssh myuser@win2019.

Openssh github web

We want also to turn on PowerShell Remoting over SSH, so we can create PSSession objects from PowerShell Core on Linux/MacOs/Windows.

Acknowledgments

This work is a compilation of the pages found on Microsoft's official documentation and community:

Openssh Windows Github

Login Shell on Windows Server 2019 core

Let me repeat the title.. Do this ONLY on Windows Core Edition. This will allow you to login with a PowerShell sessio directly.

Roxio toast for mac download. If you are on the console, you must be in a cmd.exe, so start a powershell and type these instructions:

Install PowerShell Core

Even if you don't configure PowerShell Remoting over SSH, PowerShell Core is a Good Thing (tm) to have on your machines.

First download the install from PowerShell's official github (as of this writing we are on 6.2.3 with 7.0.0 lurking around the corner):

Then, go ahead and install it:

Deploy and Configure OpenSSH

First, install both the SSH Client and Server:

To be able to use SSH keys to authenticate, install the following module:

Openssh Github App

Then, start the SSH Agent and the SSH Server services:

You can check the Firewall rule like this:

Configure Powershell to be the default shell when remoting in via SSH:

Configure you SSH environment on the Windows server so you can add your SSH public key to authenticate:

Configure PowerShell Remoting over SSH

The final touch is to allow PSSession over SSH. Open the SSHD Config file at C:ProgramDataSSHsshd_config,and modify the line that allow public keys to authenticate:

Then add a new ssh subsystem after sftp:

Note: Make sure to use the MS-DOS 8.3 path notation with / to point to the PowerShell executable. Otherwise the SSHD server will fail incoming sessions with some obscure error like:

Final step! Reboot the server (Restarting the sshd service does not seem sufficient in my experience):

Connect!

ssh

The first test will be to connect via ssh, the first time, you should force password authentication:

Then add you public key (typically ~/.ssh/id_rsa.pub) to the authorized keys of the Windows server:

Win32 Openssh

Subsequent ssh sessions will look like:

Negociation will happen with the public key.. No more passwords!

Openssh Github Win64

PowerShell Core sessions

Openssh Github Powershell

If you are familiar with sessions in PowerShell, this will be easy. The main difference is the SSH parameters: