In my application I want to determine if public key authentication is enabled
in the remote node.
So I set the logger first and connect to the target machine and check the log
for "Authentications that can continue: publickey" as shown below
JschLogger jschLogger=new JschLogger();
JSch.setLogger(jschLogger);
RunCommandUserInfo ui = new RunCommandUserInfo("password");
Properties configProps = new Properties();
configProps.put("PreferredAuthentications","publickey");
session.setConfig(configProps);
session.setUserInfo(ui);
session.connect();
session.disconnect();
DevNullLogger devNull=new DevNullLogger();
JSch.setLogger(devNull);
In the logger I check for the string "Authentications that can continue:
publickey" to confirm public key authentication is enabled.
public void log(int level, String message)
{
if(message!=null && message.trim().indexOf("Authentications that
can continue: publickey")>=0)
{
System.out.println("public key authentication supported");
}
}
The issue with this method is in a multi threaded scenario the log information
is messed up, since the jsch Logger is static.
So is there a better way to determine if public key authentication is enabled
in the remote node or is there a way to make above method thread safe.
thanks,
Prakash
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users