Commit 9f007aac authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Fix sftp client

parent 03edd7b6
Pipeline #8288 failed with stages
in 2 minutes and 2 seconds
......@@ -74,7 +74,6 @@ class SettingsLoader {
sftpSettings.setProperty("port", addSetting("sftp", "port"))
sftpSettings.setProperty("user", addSetting("sftp", "user"))
sftpSettings.setProperty("password", addSetting("sftp", "password"))
sftpSettings.setProperty("fingerprint", addSetting("sftp", "fingerprint"))
} catch (ex: ClassCastException) {
ex.printStackTrace()
log.error("The properties file has an invalid structure: $ex")
......
......@@ -20,7 +20,6 @@ package org.memobase
import java.io.Closeable
import java.io.File
import java.io.IOException
import java.net.ConnectException
import java.net.UnknownHostException
import java.util.Properties
......@@ -31,6 +30,7 @@ import net.schmizz.sshj.sftp.FileMode
import net.schmizz.sshj.sftp.OpenMode
import net.schmizz.sshj.sftp.RemoteFile
import net.schmizz.sshj.sftp.SFTPClient
import net.schmizz.sshj.transport.verification.PromiscuousVerifier
import net.schmizz.sshj.userauth.UserAuthException
import org.apache.logging.log4j.LogManager
......@@ -40,13 +40,8 @@ class SftpClient(sftpSettings: Properties) : Closeable {
private val instance: SFTPClient
init {
try {
try {
ssh.loadKnownHosts()
} catch (ex: IOException) {
log.warn(ex.message)
}
ssh.addHostKeyVerifier(sftpSettings.getProperty("fingerprint"))
ssh.connect(sftpSettings.getProperty("host"))
ssh.addHostKeyVerifier(PromiscuousVerifier())
ssh.connect(sftpSettings.getProperty("host"), sftpSettings.getProperty("port").toInt())
ssh.authPassword(sftpSettings.getProperty("user"), sftpSettings.getProperty("password"))
instance = ssh.newSFTPClient()
} catch (ex: UserAuthException) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment