Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ihmc-cd functionality #80

Merged
merged 5 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/main/kotlin/us/ihmc/build/IHMCBuildPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class IHMCBuildPlugin : Plugin<Project>
{
override fun apply(project: Project)
{
// add deploy task
project.extensions.add("app", AppExtension(project))
// add SFTP extension
project.extensions.add("remote", RemoteExtension())

LogTools = IHMCBuildLogTools(project.logger)
Expand Down
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"))
ds58 marked this conversation as resolved.
Show resolved Hide resolved
{
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!")
ds58 marked this conversation as resolved.
Show resolved Hide resolved
throw e
}
}

sshClient.connect(address)
Expand Down