Reputation: 3
I am using ganymed-ssh2 to carry out remote execution of commands provided in a xml config file. It works fine for most of the servers except for some where i am getting the following error.
java.io.IOException: Password authentication failed. at ch.ethz.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:300) at ch.ethz.ssh2.Connection.authenticateWithPassword(Connection.java:309) at GenericAccessOnly.GenericAccessOnly.Access(GenericAccessOnly.java:260) at GenericAccessOnly.GenericAccessOnly.main(GenericAccessOnly.java:190) Caused by: java.io.IOException: Authentication method password not supported by the server at this stage. at ch.ethz.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:270) ... 3 more
Any help in this regard will certainly of great help.
Regards
Upvotes: 0
Views: 3338
Reputation: 5928
Well.. The exception really speaks for itself, doesn't it? The server in question simply does not support password authentication. You should implement code that tries different authentication approaches supported by ganymed-ssh2.
There is example code included in ganymed-ssh2, which explains how to check available auth methods. Example:
if (connection.isAuthMethodAvailable(getUsername(), "publickey")) {
System.out.println("--> public key auth method supported by server");
} else {
System.out.println("--> public key auth method not supported by server");
}
if (connection.isAuthMethodAvailable(getUsername(), "keyboard-interactive")) {
System.out.println("--> keyboard interactive auth method supported by server");
} else {
System.out.println("--> keyboard interactive auth method not supported by server");
}
if (connection.isAuthMethodAvailable(getUsername(), "password")) {
System.out.println("--> password auth method supported by server");
} else {
System.out.println("--> password auth method not supported by server");
}
Here are the examples. Take a look at SwingShell which uses more than just password auth.
Upvotes: 1