Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PuTTY Storing Host Keys in Windows Registry

1,223 views
Skip to first unread message

johncal...@gmail.com

unread,
Aug 16, 2016, 3:53:40 AM8/16/16
to
Hello,

I have a question regarding PuTTY, which is stemming from a problem I
am facing at the moment.

I am writing a Python program using the modules paramiko and pysftp.
These modules are looking for the Host Key in
/users/{username}/.ssh/known_hosts, yet PuTTY insists on storing the
key in the Windows Registry.

Is there a way to convince PuTTY to store the host keys in a location
where my Python modules can read them?

Any help you can provide would be greatly appreciated.

Michael Brausen

unread,
Aug 17, 2016, 4:19:14 AM8/17/16
to
Hi,

While I am also not a friend of storing information in the Windows
Registry you actually can read the SSH keys easily (as Python comes with
"batteries included" all is already there):

https://docs.python.org/3.5/library/winreg.html

import winreg

key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r'Software\ \
SimonTatham\PuTTY\SshHostKeys', 0, winreg.KEY_READ)
for i in range(winreg.QueryInfoKey(key)[1]):
print(winreg.EnumValue(key, i))

HTH!

-Michael

Am 16.08.16 um 09:53 schrieb johncal...@gmail.com:

johncal...@gmail.com

unread,
Aug 17, 2016, 3:53:17 PM8/17/16
to
Thank you!

This is the only response I've received regardding this problem from
the wide range of sources.

I appreciate your help.

pjraut...@gmail.com

unread,
Jun 2, 2017, 12:30:39 AM6/2/17
to
Connect to the server first with a Windows ssh client that uses the known_hosts file.
PuTTy stores the data in the windows registry,however OpenSSH uses the known_hosts file, and will add entries in there after you connect.
Default location for the file is %USERPROFILE%\.ssh. I hope this helps
0 new messages