Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to disable known host checking with JSch?

Tags:

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. I can investigate that later but, for now, I would prefer to skip that step. Does anybody know if it is doable and how?

like image 365
amphibient Avatar asked Oct 19 '12 15:10

amphibient


People also ask

How to disable SSH host key checking?

Disable with SSH Command You can define the StrictHostKeyChecking=no command line argument to ssh command to skip the host key checking.

What is known hosts in JSch?

public class KnownHosts extends Object implements HostKeyRepository. Usually not to be used by applications. The default implementation of HostKeyRepository , using a local file to store the keys. I see no reason this class has to be public. See Also: JSch.setKnownHosts(String) , JSch.setKnownHosts(InputStream)

What does StrictHostKeyChecking no do?

The strict-host-key-checking command specifies how host keys are checked during the connection and authentication phase. By default, strict host key checking is disabled. When disabled the SSH client verifies the incoming host key against the keys in the known hosts list.


1 Answers

Have you tried the following:

session.setConfig("StrictHostKeyChecking", "no"); 

From this thread

like image 131
Brian Agnew Avatar answered Nov 03 '22 19:11

Brian Agnew