Commit cd81d037 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

replace host key verifier

All host keys will now by accepted.
parent 527a3795
......@@ -86,7 +86,6 @@ class SettingsLoader(private val fileName: String) {
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")
......
......@@ -18,21 +18,21 @@
package org.memobase
import java.io.Closeable
import java.io.File
import java.net.ConnectException
import java.net.UnknownHostException
import kotlin.system.exitProcess
import net.schmizz.sshj.SSHClient
import net.schmizz.sshj.sftp.SFTPClient
import net.schmizz.sshj.sftp.FileAttributes
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.sftp.OpenMode
import net.schmizz.sshj.transport.verification.PromiscuousVerifier
import net.schmizz.sshj.userauth.UserAuthException
import org.apache.logging.log4j.LogManager
import java.io.IOException
import java.io.Closeable
import java.io.File
import java.net.ConnectException
import java.net.UnknownHostException
import java.util.Properties
import kotlin.system.exitProcess
class SftpClient(sftpSettings: Properties) : Closeable {
private val log = LogManager.getLogger("SftpClient")
......@@ -40,12 +40,7 @@ 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.addHostKeyVerifier(PromiscuousVerifier())
ssh.connect(sftpSettings.getProperty("host"))
ssh.authPassword(sftpSettings.getProperty("user"), sftpSettings.getProperty("password"))
instance = ssh.newSFTPClient()
......
......@@ -3,7 +3,6 @@ sftp:
port: ${SFTP_PORT:?system}
user: ${SFTP_USER:?system}
password: ${SFTP_PASSWORD:?system}
fingerprint: ${HOST_KEY_VERIFIER:?system}
app:
csv:
header:
......
sftp:
host: sb-uingest1.swissbib.unibas.ch
port: 22
user: mb_sftp
password: ${SFTP_PASSWORD:?env}
fingerprint: ${HOST_KEY_VERIFIER:?env}
user: user
password: password
app:
csv:
header:
......
sftp:
host: sb-uingest1.swissbib.unibas.ch
port: 22
user: mb_sftp
password: ${SFTP_PASSWORD:?env}
fingerprint: ${HOST_KEY_VERIFIER:?env}
user: user
password: password
app:
csv:
header:
......
Supports Markdown
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