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?



The known_hosts file has a pretty standard format:

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


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

You could try just building it yourself.

  • 1
    do i need to generate the public key? or is it already within the PuTTy registry data? – amphibient Oct 19 '12 at 16:23
  • 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 Oct 19 '12 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.