Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-24273] Thrilead SSH throws IOE when passed an unknown …
…keytype
  • Loading branch information
stephenc committed Aug 15, 2014
1 parent 5c60c86 commit a5fb404
Showing 1 changed file with 13 additions and 3 deletions.
Expand Up @@ -35,6 +35,7 @@
import hudson.util.Secret;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -102,16 +103,25 @@ protected boolean doAuthenticate() {
Collection<String> availableMethods = getRemainingAuthMethods();
if (availableMethods.contains("publickey")) {
int count = 0;
List<IOException> ioe = new ArrayList<IOException>();
for (String privateKey : getPrivateKeys(user)) {
if (connection.authenticateWithPublicKey(username, privateKey.toCharArray(), passphrase)) {
LOGGER.fine("Authentication with 'publickey' succeeded.");
return true;
try {
if (connection.authenticateWithPublicKey(username, privateKey.toCharArray(), passphrase)) {
LOGGER.fine("Authentication with 'publickey' succeeded.");
return true;
}
} catch (IOException e) {
ioe.add(e);
}
count++;
getListener()
.error("Server rejected the %d private key(s) for %s (credentialId:%s/method:publickey)",
count, username, user.getId());
}
for (IOException e : ioe) {
e.printStackTrace(getListener()
.error("Failed to authenticate as %s with credential=%s", username, getUser().getId()));
}
return false;
} else {
getListener().error("The server does not allow public key authentication. Available options are %s",
Expand Down

0 comments on commit a5fb404

Please sign in to comment.