SSH Key Conversion

In order to convert the key into the OpenSSH format, you will need the OpenSSH tool set installed on a system.

Installation

Windows 10 1809 & Windows Server 2019 or newer

Newer windows can install OpenSSH as a Windows capability:

Source: https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse

In an elevated powershell console:

Get-WindowsCapability -Online | ? Name -like 'OpenSSH*
# This should return the following output:

Name  : OpenSSH.Client~~~~0.0.1.0
State : NotPresent
Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

# Both of these should return the following output:

Path          :
Online        : True
RestartNeeded : False

Older Windows Systems

Install a package installer like Choco and install OpenSSH from there.

Source: https://chocolatey.org/docs/installation

In an elevated powershell console:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Use Choco to install OpenSSH:

choco install openssh -Y

Windows alternative: Install Powershell Core

Install via Choco:

choco install powershell-core -Y

Or download and install from github:

https://github.com/PowerShell/PowerShell/releases/latest

Windows alternative: Use puttygen.exe

If your key is in ppk format, you can use puttygen.exe to convert to openssh formats:

https://aws.amazon.com/premiumsupport/knowledge-center/convert-pem-file-into-ppk/

Linux Systems

OpenSSH is likely already installed, but the installation procedure is as follows

# Centos, RHEL, Fedora
yum -y install openssh
# Debian, Ubuntu, Mint
apt -y install openssh

The OpenSSH official Homepage:

http://www.openssh.com/

Once you get the correct version installed and working you will need to use the following commands.

OpenSSH

The command below can be used to convert an SSH2 private key into the OpenSSH format:

ssh-keygen -i -f path/to/private.key > path/to/new/opensshprivate.key

The command below can be used to convert an SSH2 public key into the OpenSSH format:

ssh-keygen -i -f path/to/publicsshkey.pub >> path/to/publickey.pub

SSH2

This can also be done in reverse to convert an OpenSSH key into the SSH2 format in the event that a client application requires the other format. This can be done using the following command:

Private key conversion:

ssh-keygen -e -f path/to/opensshprivatekey/file > path/to/ssh2privatekey/file

Public key conversion:

ssh-keygen -e -f path/to/opensshprivatekey/file > path/to/ssh2privatekey/file

The most important thing to remember when using these commands are the flags. The -i tells SSH to read an SSH2 key and convert it into the OpenSSH format. The -e parameter tells SSH to read an OpenSSH key file and convert it to SSH2. With these commands you should be able to successfully covert SSH keys between the different formats required by MessageWay as well as other file transfer applications.