Al LastName - 2008-07-13

Could you please provide an example code how to use JSch library in non-interactive mode?
I would like to use it in my service to run commands on my linux box through SSH.
There's no GUI there and I don't want to use UserInfo class - it looks like an overkill. I just want to provide host name, user name, password and command. I don't see why I should override promptYesNo() and all other methods.
the library could just throw exceptions and I can catch them and do anything I need.

So, the problem I have now is that it throws exception when I connect to a host, which is not added to "allowed hosts" list.

What would be nice:
add option "ignore unknown host exception" or "auto-add unknown hosts to allowed hosts list"
I don't care for security inside my local network.
all I need to do is to connect to my machine. I don't know its RSA key and I don't see a way to add that key to JSch in non-interactive mode.
I can't even catch "unknown host" exception to override it with something, like this:
           try {
           } catch (JSchException e) {
               if (e.getMessage().startsWith("UnknownHostKey:")) {
                   // ignore or ADD here
               } else {
                   throw e; // re-throw it back
if session.connect would throw something like "HostNotFoundInAllowedHostsException" with method getRSA(), then I could use that info:
           try {
           } catch (HostNotFoundInAllowedHostsException e) {
               add the key somehow - HOW??

In general, it would be great if JSch was oriented to work in NON-interactive mode. I see currently it is mostly designed for UI usage.

Alexey Skorokhodov.