diff options
author | Udo Walter | 2021-03-16 20:31:23 +0100 |
---|---|---|
committer | Udo Walter | 2021-03-16 20:31:23 +0100 |
commit | 5bb76109326829a821fd99deb8a40c196573a8bb (patch) | |
tree | 62de75b442221c29222fcf2d301952c03c054850 | |
parent | [RemoteExec/RemoteReboot] convert ssh key to a format supported by JSch (diff) | |
download | tmlite-bwlp-5bb76109326829a821fd99deb8a40c196573a8bb.tar.gz tmlite-bwlp-5bb76109326829a821fd99deb8a40c196573a8bb.tar.xz tmlite-bwlp-5bb76109326829a821fd99deb8a40c196573a8bb.zip |
[RemoteExec/RemoteReboot] switch to fork of JSch to support more key formats
-rw-r--r-- | pom.xml | 14 | ||||
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/RemoteExec.java | 13 | ||||
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/RemoteReboot.java | 15 |
3 files changed, 2 insertions, 40 deletions
@@ -111,24 +111,14 @@ <scope>compile</scope> </dependency> <dependency> - <groupId>com.jcraft</groupId> + <groupId>com.github.mwiede</groupId> <artifactId>jsch</artifactId> - <version>0.1.54</version> + <version>0.1.62</version> </dependency> <dependency> <groupId>org.schwering</groupId> <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 8e88599..3bd0954 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/RemoteExec.java +++ b/src/main/java/org/openslx/taskmanager/tasks/RemoteExec.java @@ -9,10 +9,6 @@ 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; @@ -81,15 +77,6 @@ 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 1913891..2776732 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/RemoteReboot.java +++ b/src/main/java/org/openslx/taskmanager/tasks/RemoteReboot.java @@ -1,9 +1,7 @@ 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; @@ -15,10 +13,6 @@ 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; @@ -87,15 +81,6 @@ 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 ); |