~jan0sch/smederee

Showing details for patch 5d28e364c518360fa5abc503938c8ca2dba5623d.
2022-08-26 (Fri), 10:52 AM - Jens Grassel - 5d28e364c518360fa5abc503938c8ca2dba5623d

SSH: Proof of Concept for cloning via SCP

Summary of changes
1 files modified with 18 lines added and 8 lines removed
  • modules/hub/src/main/scala/de/smederee/ssh/SshServer.scala with 18 added and 8 removed lines
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/ssh/SshServer.scala new-smederee/modules/hub/src/main/scala/de/smederee/ssh/SshServer.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/ssh/SshServer.scala	2025-02-02 14:45:45.974405100 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/ssh/SshServer.scala	2025-02-02 14:45:45.974405100 +0000
@@ -9,17 +9,21 @@
 
 package de.smederee.ssh
 
-import java.nio.file._
+import java.nio.file.*
+import java.util.Collections
 
-import cats._
-import cats.data._
-import cats.effect._
-import cats.syntax.all._
-import com.comcast.ip4s._
+import cats.*
+import cats.data.*
+import cats.effect.*
+import cats.syntax.all.*
+import com.comcast.ip4s.*
 import de.smederee.hub.config.ConfigKey
+import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory
+import org.apache.sshd.scp.server.ScpCommandFactory
 import org.apache.sshd.server.SshServer
 import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider
-import pureconfig._
+import org.apache.sshd.sftp.server.SftpSubsystemFactory
+import pureconfig.*
 
 import scala.util.matching.Regex
 
@@ -109,6 +113,12 @@
     server.setKeyPairProvider(keyProvider)
     server.setPublickeyAuthenticator(new SshAuthenticator(configuration.genericUser))
     server.setShellFactory(new NoLogin(configuration.genericUser, configuration.host, configuration.port))
+    // FIXME Use SCP/SFTP as long as darcs support is missing (see https://github.com/apache/mina-sshd/blob/master/docs/sftp.md)
+    val sftpSubsystem = new SftpSubsystemFactory.Builder().build()
+    server.setSubsystemFactories(Collections.singletonList(sftpSubsystem))
+    server.setFileSystemFactory(new VirtualFileSystemFactory(Paths.get("/home/jens/tmp/smederee")))
+    val scpCommand = new ScpCommandFactory.Builder().build()
+    server.setCommandFactory(scpCommand)
     server
   }