How to export known_hosts file from PuTTy?

3

3

I am trying to kick the tires of JSch and SSH connect to remote (Solaris) host from Java locally. I normally use PuTTy, which gives me a prompt about an unknown host every time I connect somewhere for the first time, then I say yes and it no longer does it because it stores known hosts in the Win7 registry. But JSch expects a known_hosts file and I am not sure how to make it.

Can anybody instruct how to export the known_hosts from the Win7 registry into the file format? I cannot go into the registry directly because I am not an admin on my laptop (company policy). I can call desktop support and they will do it but I would rather not go through the step. I figure if PuTTy can access the registry when I am using it then it should be able to also export data out of it.

Any idea?

Thanks

amphibient

Posted 2012-10-19T15:17:35.070

Reputation: 1 613

1

There is a python script which allegedly does what you need: http://kobowi.co.uk/blog/2011/08/convert-winscpputty-ssh-host-keys-to-known_hosts-format/

– JimmyB – 2012-11-30T08:59:26.213

Answers

3

The known_hosts file has a pretty standard format:

<hostname>[,<hostname2>...] ssh-rsa|ssh-dsa <ssh public key>

Ex.

example.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEA0d7Aoure0toNJ+YMYi61QP2ka8m5x5ZQlT7obP8CK3eropfqsMPPY6uiyIh9vpiFX2r1LHcbx139+vG6HOtVvuS8+IfMDtawm3WQvRuOopz3vVy5GtMwtaOgehsXoT930Ryev1bH5myPtWKlipITsOd2sX9k3tvjrmme4KCGGss=

You could try just building it yourself.

Darth Android

Posted 2012-10-19T15:17:35.070

Reputation: 35 133

1do i need to generate the public key? or is it already within the PuTTy registry data? – amphibient – 2012-10-19T16:23:08.427

1@foampile If you have the private key, you can use PuTTyGen to create the public key from the private key. An alternative method is to connect to the target system from any linux-based system, and then check the ~/.ssh/known_hosts file on the system you connected from and copy the line matching the host out of that file. – Darth Android – 2012-10-19T17:05:16.207