Import from PuTTY

This article describes how to import data from PuTTY.

For that you'll need to:

  1. Convert data from PuTTY into an ssh config file.

Convert from PuTTY

The first step is to export PuTTY sessions from the registry into a putty-sessions.reg file.

Windows PowerShell
Windows PowerShell
reg export HKCU\Software\SimonTatham\PuTTY\Sessions ([Environment]::GetFolderPath("Desktop") + "\putty-sessions.reg");

The next step is to set terminal encoding to utf8.

Windows PowerShell
Windows PowerShell
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'

Lastly, convert the putty-sessions.reg file into the OpenSSH config format.

Windows PowerShell
Windows PowerShell
cat .\putty-sessions.reg |
where { $_ -match '("HostName")|("UserName")|("PortNumber")|(HKEY_CURRENT_USER.+Sessions\\)' } |
%{ if ($ -match 'dword:') { $port= ($ -replace '"','' -replace 'PortNumber=dword:', '0x'); " Port $($port -as [int])" } else { $_ } } |
%{ $_ -replace 'HKEY_CURRENT_USER.+Sessions\\', 'Host ' -replace '[\[\]]',''} |
%{ $_ -replace '"HostName"=',' HostName ' -replace '"UserName"=',' User ' -replace '"PortNumber"=',' Port ' -replace '"PublicKeyFile"=',' IdentifyFile ' } > ssh_config
Converting from PuTTY