Skip to content

Commit

Permalink
Add host key verification skip system property
Browse files Browse the repository at this point in the history
  • Loading branch information
ds58 committed Sep 20, 2024
1 parent 6eb4875 commit 2ff3bbd
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main/kotlin/us/ihmc/cd/RemoteExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import net.schmizz.sshj.connection.channel.direct.Session
import net.schmizz.sshj.sftp.SFTPClient
import net.schmizz.sshj.transport.verification.OpenSSHKnownHosts
import net.schmizz.sshj.transport.verification.PromiscuousVerifier
import org.apache.commons.exec.OS
import org.gradle.api.Action
import us.ihmc.build.LogTools
import java.io.IOException
Expand Down Expand Up @@ -99,17 +100,22 @@ open class RemoteExtension
{
val sshClient = SSHClient()

val sshDir = OpenSSHKnownHosts.detectSSHDir()

if (sshDir.resolve("known_hosts").isFile)
try
{
sshClient.loadKnownHosts()
}
else
catch (e: Exception)
{
LogTools.warn("Could not find known_hosts file. Disabling host key verification.")

sshClient.addHostKeyVerifier(PromiscuousVerifier())
if (System.getProperty("ignoreHostIdentity", "false").equals("true"))
{
LogTools.warn("Could not find known_hosts file. Disabling host key verification (using -PignoreHostIdentity=true).")
sshClient.addHostKeyVerifier(PromiscuousVerifier())
}
else
{
LogTools.warn("Could not find known_hosts file. Disable host key verification with -PignoreHostIdentity=true. Please understand the security implications of doing this!")
throw e
}
}

sshClient.connect(address)
Expand Down

0 comments on commit 2ff3bbd

Please sign in to comment.