diff --git a/drivers/jsch/.gitignore b/drivers/jsch/.gitignore deleted file mode 100644 index cb1040eb36..0000000000 --- a/drivers/jsch/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -# use glob syntax. -syntax: glob -target -.settings -.classpath -.project -jclouds-jsch.iml -jclouds-jsch.ipr -jclouds-jsch.iws \ No newline at end of file diff --git a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/SessionConnection.java b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/SessionConnection.java index fca26a0494..2ff4e75a51 100644 --- a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/SessionConnection.java +++ b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/SessionConnection.java @@ -169,11 +169,11 @@ public final class SessionConnection implements Connection { .getSession(loginCredentials.getUser(), hostAndPort.getHostText(), hostAndPort.getPortOrDefault(22)); if (sessionTimeout != 0) session.setTimeout(sessionTimeout); - if (loginCredentials.getOptionalPassword().isPresent()) { - session.setPassword(loginCredentials.getOptionalPassword().orNull()); - } else if (loginCredentials.hasUnencryptedPrivateKey()) { + if (loginCredentials.hasUnencryptedPrivateKey()) { byte[] privateKey = loginCredentials.getOptionalPrivateKey().get().getBytes(); jsch.addIdentity(loginCredentials.getUser(), privateKey, null, emptyPassPhrase); + } else if (loginCredentials.getOptionalPassword().isPresent()) { + session.setPassword(loginCredentials.getOptionalPassword().orNull()); } else if (agentConnector.isPresent()) { JSch.setConfig("PreferredAuthentications", "publickey"); jsch.setIdentityRepository(new RemoteIdentityRepository(agentConnector.get()));