DaanHoogland commented on a change in pull request #5831:
URL: https://github.com/apache/cloudstack/pull/5831#discussion_r797749584
##########
File path: utils/src/main/java/com/cloud/utils/ssh/SshHelper.java
##########
@@ -118,6 +124,42 @@ public static void scpTo(String host, int port, String
user, File pemKeyFile, St
}
}
+ public static void scpTo(String host, int port, String user, File
pemKeyFile, String password, String remoteTargetDirectory, String[] localFiles,
String fileMode,
+ int connectTimeoutInMs, int kexTimeoutInMs)
throws Exception {
+
+ com.trilead.ssh2.Connection conn = null;
+ com.trilead.ssh2.SCPClient scpClient = null;
+
+ try {
+ conn = new com.trilead.ssh2.Connection(host, port);
+ conn.connect(null, connectTimeoutInMs, kexTimeoutInMs);
+
+ if (pemKeyFile == null) {
+ if (!conn.authenticateWithPassword(user, password)) {
+ String msg = "Failed to authentication SSH user " + user +
" on host " + host;
+ s_logger.error(msg);
+ throw new Exception(msg);
+ }
+ } else {
+ if (!conn.authenticateWithPublicKey(user, pemKeyFile,
password)) {
+ String msg = "Failed to authentication SSH user " + user +
" on host " + host;
+ s_logger.error(msg);
+ throw new Exception(msg);
Review comment:
sure we can be more specific about what we throw here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]