Import from PuTTY

This article describes how to import data from PuTTY.

For that you'll need to:

  1. Export the data from PuTTY, which is stored in the registry.

  2. Convert it into an ssh config file.

Converting from PuTTY

Export from PuTTY

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

This command creates a 'putty-sessions.reg' file in the desktop directory.

Convert reg to SSH Config

Windows PowerShell
Windows PowerShell
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
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

Substitute '.\putty-sessions.reg' with the location of the 'putty-sessions.reg' file.