Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from glob import glob
import os
session_files = glob(os.environ["HOME"] + "/.putty/sessions/*")
out_file = open("putty-sessions.reg", "w")
header = '''Windows Registry Editor Version 5.00
for fpath in session_files:
f = open(fpath, "r")
lines = f.readlines()
fname = fpath.split('/')[-1]
out_file.write("\n[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\%s]\n" % fname)
for line in lines:
data = line.split("=")
key = data[0]
val = data[1].strip()
out_file.write("\"%s\"=" % key)
out_file.write("dword:%s\n" % val.zfill(8))
out_file.write("\"%s\"\n" % val)

This comment has been minimized.

Copy link
Owner Author

@ezr ezr commented Mar 24, 2020

This is a python script that you can run on a linux system whose putty sessions are saved under ~/.putty/sessions/. The purpose is to migrate the info into a .reg file which can be imported on windows.

Very lightly tested. USE AT YOUR OWN RISK. If anyone attempts to use this then make sure to back up the registry keys on windows before making any changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment