From cea906e5644b480179ed12d6a69275fab727ccd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9sz=C3=A1ros=20Martin=20=28MESZARM=29?= Date: Fri, 30 Aug 2024 16:37:24 +0200 Subject: [PATCH] Create tmp dir for SSH key --- .../meshcloud/dockerosb/config/CustomSshSessionFactory.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/io/meshcloud/dockerosb/config/CustomSshSessionFactory.kt b/src/main/kotlin/io/meshcloud/dockerosb/config/CustomSshSessionFactory.kt index 37234cb..0bc09fe 100644 --- a/src/main/kotlin/io/meshcloud/dockerosb/config/CustomSshSessionFactory.kt +++ b/src/main/kotlin/io/meshcloud/dockerosb/config/CustomSshSessionFactory.kt @@ -8,6 +8,8 @@ import org.eclipse.jgit.transport.ssh.jsch.OpenSshConfig import org.eclipse.jgit.util.FS import org.eclipse.jgit.util.FileUtils import java.io.File +import java.nio.file.Files +import java.nio.file.Paths class CustomSshSessionFactory( private val sshKey: String @@ -34,7 +36,9 @@ class CustomSshSessionFactory( val content = sshKey.substring(contentStartIndex, contentEndIndex).replace(" ", "\n") val formattedKey = sshKey.substring(0, contentStartIndex) + content + sshKey.substring(contentEndIndex, sshKey.length - 1) - File(keyPath).writeText(formattedKey) + val keyFile = File(keyPath) + Files.createDirectories(Paths.get(keyFile.parent)) + keyFile.writeText(formattedKey) val jsch = super.getJSch(hc, fs) jsch.removeAllIdentity()