Saturday, November 11, 2017

save and restore of putty session definitions from machine to machine

Putty sessions are saved in the registry entries for the Putty application.   That entry for the user must be backed up and restored to transfer the session information between machines.

This incantation will back up the registry entries for a user to a file.

regedit /e "%userprofile%\desktop\putty-registry.reg" HKEY_CURRENT_USER\Software\Simontatham

The "manufacturer is "Simontatham" and is the same on all machines.

This saves the session entries in a Desktop file putty-registry.reg

File names on machine on restore (Merge):
In each Session entry there will be a location for any sessions which have a key file set for SSH preshared key.  It is not a good idea to save and transfer the preshared keys between machines, unless they are ones you have generated, and know what you are doing.

"PublicKeyFile" will be the path to the preshared key, and will need to point at the location for the preshared private key file on the new machine.  This should be done before merging and restoring onto the machine.

Restore (Merge):
This incantation will allow one to restore them on another machine.

The saved file will need to be located on a drive with a drive letter.  Otherwise the restore will not work.  Copying the putty-registry.reg file back to the new machine Desktop would be a good way to ensure this (it will be on C:).

Double clicking on the reg file once transferred to the other machine will restore those registry keys, and they should appear on the next invocation of putty.

You can also run regedit (from the run feature of the start menu) and select to import the file.

stackoverflow article method here


cmd.exe, require elevated prompt:

Only sessions:
regedit /e "%USERPROFILE%\Desktop\putty-sessions.reg" HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions
All settings:
regedit /e "%USERPROFILE%\Desktop\putty.reg" HKEY_CURRENT_USER\Software\SimonTatham


Only sessions:
reg export HKCU\Software\SimonTatham\PuTTY\Sessions ([Environment]::GetFolderPath("Desktop") + "\putty-sessions.reg")
All settings:
reg export HKCU\Software\SimonTatham ([Environment]::GetFolderPath("Desktop") + "\putty.reg")


Double-click on the *.reg file and accept the import.

Alternative ways:

cmd.exe, require 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: It will create a reg file on the Desktop of the current user.
Note: It will not export related SSH keys.


No comments:

Post a Comment