Is there a way to do this?
Or I have to take manually every record from Registry?
cmd.exe
, requires elevated prompt due to regedit:Only sessions (produces file putty-sessions.reg
on the Desktop):
regedit /e "%USERPROFILE%\Desktop\putty-sessions.reg" HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions
All settings except ssh keys (produces file putty.reg
on the Desktop):
regedit /e "%USERPROFILE%\Desktop\putty.reg" HKEY_CURRENT_USER\Software\SimonTatham
Only sessions (produces file putty-sessions.reg
on the Desktop):
reg export HKCU\Software\SimonTatham\PuTTY\Sessions ([Environment]::GetFolderPath("Desktop") + "\putty-sessions.reg")
All settings except ssh keys (produces file putty.reg
on the Desktop):
reg export HKCU\Software\SimonTatham ([Environment]::GetFolderPath("Desktop") + "\putty.reg")
Double-click on the *.reg
file and accept the import.
cmd.exe
, requires elevated command prompt:regedit /i putty-sessions.reg
regedit /i putty.reg
reg import putty-sessions.reg
reg import putty.reg
Note: do not replace SimonTatham
with your username.
Note: These commands will not export the related SSH keys.
HKEY_CURRENT_USER\...
. Elevated rights are required only for HKEY_LOCAL_MACHINE
, HKEY_CLASSES_ROOT
, etc.
Nov 15, 2018 at 21:42
HKEY_LOCAL_MACHINE\SOFTWARE\SimonTatham\PuTTY64
.
Feb 17, 2019 at 11:04
regedit
in the open drop down windowHKEY_CURRENT_USER\Software\SimonTatham
putty.reg
and save it to your location for later use.Done.
When I tried the other solutions I got this error:
Registry editing has been disabled by your administrator.
Phooey to that, I say!
I put together the below powershell scripts for exporting and importing PuTTY settings. The exported file is a windows .reg file and will import cleanly if you have permission, otherwise use import.ps1 to load it.
Warning: messing with the registry like this is a Bad Idea™, and I don't really know what I'm doing. Use the below scripts at your own risk, and be prepared to have your IT department re-image your machine and ask you uncomfortable questions about what you were doing.
On the source machine:
.\export.ps1
On the target machine:
.\import.ps1 > cmd.ps1
# Examine cmd.ps1 to ensure it doesn't do anything nasty
.\cmd.ps1
export.ps1
# All settings
$registry_path = "HKCU:\Software\SimonTatham"
# Only sessions
#$registry_path = "HKCU:\Software\SimonTatham\PuTTY\Sessions"
$output_file = "putty.reg"
$registry = ls "$registry_path" -Recurse
"Windows Registry Editor Version 5.00" | Out-File putty.reg
"" | Out-File putty.reg -Append
foreach ($reg in $registry) {
"[$reg]" | Out-File putty.reg -Append
foreach ($prop in $reg.property) {
$propval = $reg.GetValue($prop)
if ("".GetType().Equals($propval.GetType())) {
'"' + "$prop" + '"' + "=" + '"' + "$propval" + '"' | Out-File putty.reg -Append
} elseif ($propval -is [int]) {
$hex = "{0:x8}" -f $propval
'"' + "$prop" + '"' + "=dword:" + $hex | Out-File putty.reg -Append
}
}
"" | Out-File putty.reg -Append
}
import.ps1
$input_file = "putty.reg"
$content = Get-Content "$input_file"
"Push-Location"
"cd HKCU:\"
foreach ($line in $content) {
If ($line.StartsWith("Windows Registry Editor")) {
# Ignore the header
} ElseIf ($line.startswith("[")) {
$section = $line.Trim().Trim('[', ']')
'New-Item -Path "' + $section + '" -Force' | %{ $_ -replace 'HKEY_CURRENT_USER\\', '' }
} ElseIf ($line.startswith('"')) {
$linesplit = $line.split('=', 2)
$key = $linesplit[0].Trim('"')
if ($linesplit[1].StartsWith('"')) {
$value = $linesplit[1].Trim().Trim('"')
} ElseIf ($linesplit[1].StartsWith('dword:')) {
$value = [Int32]('0x' + $linesplit[1].Trim().Split(':', 2)[1])
'New-ItemProperty "' + $section + '" "' + $key + '" -PropertyType dword -Force' | %{ $_ -replace 'HKEY_CURRENT_USER\\', '' }
} Else {
Write-Host "Error: unknown property type: $linesplit[1]"
exit
}
'Set-ItemProperty -Path "' + $section + '" -Name "' + $key + '" -Value "' + $value + '"' | %{ $_ -replace 'HKEY_CURRENT_USER\\', '' }
}
}
"Pop-Location"
Apologies for the non-idiomatic code, I'm not very familiar with Powershell. Improvements are welcome!
If You want to import settings on PuTTY Portable
You can use the putty.reg
file.
Just put it to this path [path_to_Your_portable_apps]PuTTYPortable\Data\settings\putty.reg
. Program will import it
For those of you who need to import Putty from offline registry file e.g. when you are recovering from crashed system or simply moving to a new machine and grabbing data off that old drive there is one more solution worth mentioning:
http://www.nirsoft.net/utils/registry_file_offline_export.html
This great and free console application will export the entire registry or only a specific registry key. In my case i simply copied the registry file from an old drive to the same directory as the exporter tool and then i used following command and syntax in CMD window run as administrator:
RegFileExport.exe NTUSER.DAT putty.reg "HKEY_CURRENT_USER\Software\SimonTatham"
After importing the .reg file and starting Putty everything was there. Simple and efficient.
For those who don't want to mess with the registry, a variation of putty that saves to file has been created. It is located here: http://jakub.kotrla.net/putty/
It would be nice if the putty team would take this as an option into the main distribution.
m0nhawk's answer didn't work for me on Windows 10 - it required elevated command prompt and refused to emit a file.
This worked and didn't require elevation:
reg export HKEY_CURRENT_USER\Software\SimonTatham\PuTTY putty.reg
This was so much easier importing the registry export than what is stated above. + Simply:
Worked like a champ on Win 7 Pro.
Example:
How to transfer putty configuration and session configuration from one user account to another e.g. when created a new account and want to use the putty sessions/configurations from the old account
Process:
- Export registry key from old account into a file
- Import registry key from file into new account
Export reg key: (from OLD account)
Import reg key: (into NEW account)
Login into NEW account e.g. tom
Open normal 'command prompt' (NOT admin !)
Type 'regedit'
Select 'Import' from the menu
Select the registry file to import e.g. 'puttyconfig.reg'
Done
Note:
Do not use an 'admin command prompt' as settings are located under '[HKEY_CURRENT_USER...] 'and regedit would run as admin and show that section for the admin-user rather then for the user to transfer from and/or to.
If you, like me, installed new Windows and only after you remember about putty sessions, you can still import them, if you have old Windows hard drive or at least your old "home" directory backed up (C:\Users\<user_name>
).
In this directory there should be NTUSER.DAT
file. It is hidden by default, so you should enable hidden files in your Windows explorer or use another file browser. This file contains the HKEY_CURRENT_USER
branch of your old Windows registry.
To use it, you need to open regedit
on your new Windows, and select HKEY_USERS
key.
Then select File
-> Load Hive...
and find your old "home" directory of your old Windows installation. In this directory there should be NTUSER.DAT
file. It is hidden by default, so, if you didn't enable to show hidden files in your Windows explorer properties, then you can just manually enter file name into File name
input box of "Load Hive" dialog and press Enter. Then in the next dialog window enter some key name to load old registry into it. e.g. tmp
.
Your old registry's HKEY_CURRENT_USER
branch now should be accessible under HKEY_USERS\tmp
branch of your current registry.
Now export HKEY_USERS\tmp\Software\SimonTatham
branch into putty.reg
file, open this file in your favorite text editor and find-and-replace all HKEY_USERS\tmp
string with HKEY_CURRENT_USER
. Now save the .reg
file.
You can import now this file into your current Windows registry by double-clicking it. See m0nhawk's answer how to do this.
In the end, select HKEY_USERS\tmp
branch in the registry editor and then select File
-> Unload Hive...
and confirm this operation.
An improvement to the solution of bumerang to import data to PuTTY portable
.
Simply moving exported putty.reg
(with m0nhawk solution) to PuTTYPortable\Data\settings\
didn't work. PuTTY Portable backup the file and create a new empty one.
To workaround this issue, merge both putty.reg
copying manually the config you want to migrate from your exported putty.reg
to the newly created PuTTYPortable\Data\settings\putty.reg
below following lines.
REGEDIT4
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY]
"RandSeedFile"="D:\\Programme\\PuTTYPortable\\Data\\settings\\PUTTY.RND"
The answer posted by @m0nhawk doesn't seem to work as I test on a Windows 7 machine. Instead, using the following scripts would export/import the settings of putty:
::export
@echo off
set regfile=putty.reg
pushd %~dp0
reg export HKCU\Software\SimonTatham %regfile% /y
popd
--
::import
@echo off
pushd %~dp0
set regfile=putty.reg
if exist %regfile% reg import %regfile%
popd
Using this method it is also possible to perform mass configuration changes, such as changing the all sessions font.
Extracted from here: http://www.sysadmit.com/2015/11/putty-exportar-configuracion.html
There is a PowerShell script at ratil.life/first-useful-powershell-script-putty-to-ssh-config which can convert the sessions to a format that can be used in .ssh/config
. It can also be found on GitHub.
This excerpt contains the main guts of the code, and will print the resulting config directly to stdout:
# Registry path to PuTTY configured profiles
$regPath = 'HKCU:\SOFTWARE\SimonTatham\PuTTY\Sessions'
# Iterate over each PuTTY profile
Get-ChildItem $regPath -Name | ForEach-Object {
# Check if SSH config
if (((Get-ItemProperty -Path "$regPath\$_").Protocol) -eq 'ssh') {
# Write the Host for easy SSH use
$host_nospace = $_.replace('%20', $SpaceChar)
$hostLine = "Host $host_nospace"
# Parse Hostname for special use cases (Bastion) to create SSH hostname
$puttyHostname = (Get-ItemProperty -Path "$regPath\$_").HostName
if ($puttyHostname -like '*@*') {
$sshHostname = $puttyHostname.split("@")[-1]
}
else { $sshHostname = $puttyHostname }
$hostnameLine = "`tHostName $sshHostname"
# Parse Hostname for special cases (Bastion) to create User
if ($puttyHostname -like '*@*') {
$sshUser = $puttyHostname.split("@")[0..($puttyHostname.split('@').length - 2)] -join '@'
}
else { $sshHostname = $puttyHostname }
$userLine = "`tUser $sshUser"
# Parse for Identity File
$puttyKeyfile = (Get-ItemProperty -Path "$regPath\$_").PublicKeyFile
if ($puttyKeyfile) {
$sshKeyfile = $puttyKeyfile.replace('\', '/')
if ($prefix) { $sshKeyfile = $sshKeyfile.replace('C:', $prefix) }
$identityLine = "`tIdentityFile $sshKeyfile"
}
# Parse Configured Tunnels
$puttyTunnels = (Get-ItemProperty -Path "$regPath\$_").PortForwardings
if ($puttyTunnels) {
$puttyTunnels.split() | ForEach-Object {
# First character denotes tunnel type
$tunnelType = $_.Substring(0,1)
# Digits follow tunnel type is local port
$tunnelPort = $_ -match '\d*\d(?==)' | Foreach {$Matches[0]}
# Text after '=' is the tunnel destination
$tunnelDest = $_.split('=')[1]
if ($tunnelType -eq 'D') {
$tunnelLine = "`tDynamicForward $tunnelPort $tunnelDest"
}
ElseIf ($tunnelType -eq 'R') {
$tunnelLine = "`tRemoteForward $tunnelPort $tunnelDest"
}
ElseIf ($tunnelType -eq 'L') {
$tunnelLine = "`tLocalForward $tunnelPort $tunnelDest"
}
}
# Parse if Forward Agent is required
$puttyAgent = (Get-ItemProperty -Path "$regPath\$_").AgentFwd
if ($puttyAgent -eq 1) { $agentLine = "`tForwardAgent yes" }
# Parse if non-default port
$puttyPort = (Get-ItemProperty -Path "$regPath\$_").PortNumber
if (-Not $puttyPort -eq 22) { $PortLine = "`tPort $puttyPort" }
}
# Build output string
$output = "$hostLine`n$hostnameLine`n$userLine`n$identityLine`n$tunnelLine`n$agentLine`n"
# Output to file if set, otherwise STDOUT
if ($outfile) { $output | Out-File $outfile -Append}
else { Write-Host $output }
}
}
I use putty connection manager where you create a database of sessions. It's easy to copy and import that database to other computers.
See this handy guide