summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml10
-rw-r--r--src/main/java/org/openslx/taskmanager/tasks/RemoteExec.java13
-rw-r--r--src/main/java/org/openslx/taskmanager/tasks/RemoteReboot.java17
3 files changed, 39 insertions, 1 deletions
diff --git a/pom.xml b/pom.xml
index d880690..b128597 100644
--- a/pom.xml
+++ b/pom.xml
@@ -120,5 +120,15 @@
<artifactId>irclib</artifactId>
<version>2.0.0.Alpha3</version>
</dependency>
+ <dependency>
+ <groupId>com.sshtools</groupId>
+ <artifactId>maverick-synergy-client</artifactId>
+ <version>3.0.0-RC3</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sshtools</groupId>
+ <artifactId>maverick-bc</artifactId>
+ <version>3.0.0-RC3</version>
+ </dependency>
</dependencies>
</project>
diff --git a/src/main/java/org/openslx/taskmanager/tasks/RemoteExec.java b/src/main/java/org/openslx/taskmanager/tasks/RemoteExec.java
index 3bd0954..8e88599 100644
--- a/src/main/java/org/openslx/taskmanager/tasks/RemoteExec.java
+++ b/src/main/java/org/openslx/taskmanager/tasks/RemoteExec.java
@@ -9,6 +9,10 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import com.sshtools.common.publickey.InvalidPassphraseException;
+import com.sshtools.common.publickey.SshKeyUtils;
+import com.sshtools.common.publickey.bc.OpenSSHPrivateKeyFileBC;
+import com.sshtools.common.ssh.components.SshKeyPair;
import org.openslx.satserver.util.Util;
import org.openslx.taskmanager.api.AbstractTask;
@@ -77,6 +81,15 @@ public class RemoteExec extends AbstractTask
if ( status.error != null )
return false;
+ // Convert ssh key to old rsa format supported by JSch
+ try {
+ SshKeyPair key = SshKeyUtils.getPrivateKey(sshkey, "");
+ sshkey = new String(new OpenSSHPrivateKeyFileBC(key, "").getFormattedKey(),
+ StandardCharsets.UTF_8);
+ } catch (IOException | InvalidPassphraseException e) {
+ e.printStackTrace();
+ }
+
JSch.setConfig( "StrictHostKeyChecking", "no" );
sshClient = new JSch();
try {
diff --git a/src/main/java/org/openslx/taskmanager/tasks/RemoteReboot.java b/src/main/java/org/openslx/taskmanager/tasks/RemoteReboot.java
index f5d9a4b..1913891 100644
--- a/src/main/java/org/openslx/taskmanager/tasks/RemoteReboot.java
+++ b/src/main/java/org/openslx/taskmanager/tasks/RemoteReboot.java
@@ -1,7 +1,9 @@
package org.openslx.taskmanager.tasks;
+import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
+import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -13,6 +15,10 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import com.sshtools.common.publickey.InvalidPassphraseException;
+import com.sshtools.common.publickey.SshKeyUtils;
+import com.sshtools.common.publickey.bc.OpenSSHPrivateKeyFileBC;
+import com.sshtools.common.ssh.components.SshKeyPair;
import org.openslx.taskmanager.api.AbstractTask;
import com.google.gson.annotations.Expose;
@@ -80,7 +86,16 @@ public class RemoteReboot extends AbstractTask
if ( status.error != null )
return false;
-
+
+ // Convert ssh key to old rsa format supported by JSch
+ try {
+ SshKeyPair key = SshKeyUtils.getPrivateKey(sshkey, "");
+ sshkey = new String(new OpenSSHPrivateKeyFileBC(key, "").getFormattedKey(),
+ StandardCharsets.UTF_8);
+ } catch (IOException | InvalidPassphraseException e) {
+ e.printStackTrace();
+ }
+
Date shutdownTime = new Date( System.currentTimeMillis() + minutes * 60 * 1000 );
SimpleDateFormat sdf = new SimpleDateFormat( "HH:mm" );
status.time = sdf.format( shutdownTime );