diff --git a/src/main/groovy/org/ajoberstar/grgit/auth/AuthConfig.groovy b/src/main/groovy/org/ajoberstar/grgit/auth/AuthConfig.groovy
index 8a76ea9d..4d725787 100644
--- a/src/main/groovy/org/ajoberstar/grgit/auth/AuthConfig.groovy
+++ b/src/main/groovy/org/ajoberstar/grgit/auth/AuthConfig.groovy
@@ -57,6 +57,14 @@ import org.ajoberstar.grgit.exception.GrgitException
*
* - {@code org.ajoberstar.grgit.auth.ssh.private=}
*
+ *
+ * In order to add a non-standard session config,
+ * use the following property.
+ *
+ *
+ *
+ * - {@code org.ajoberstar.grgit.auth.session.config.=}
+ *
*
*
* The following order is used to determine which authentication option
@@ -80,6 +88,7 @@ class AuthConfig {
static final String USERNAME_OPTION = 'org.ajoberstar.grgit.auth.username'
static final String PASSWORD_OPTION = 'org.ajoberstar.grgit.auth.password'
static final String SSH_PRIVATE_KEY_OPTION = 'org.ajoberstar.grgit.auth.ssh.private'
+ static final String SSH_SESSION_CONFIG_OPTION_PREFIX = 'org.ajoberstar.grgit.auth.session.config.'
/**
* Set of all authentication options that are allowed in this
@@ -127,6 +136,16 @@ class AuthConfig {
return System.properties[SSH_PRIVATE_KEY_OPTION]
}
+ /**
+ * Gets session config override for SSH session that is used underneath by JGit
+ * @return map with configuration or empty if nothing was specified in system property
+ */
+ Map getSessionConfig() {
+ return System.properties
+ .findAll { it -> it.key.startsWith(SSH_SESSION_CONFIG_OPTION_PREFIX) }
+ .collectEntries { it -> [ it.key.substring(SSH_SESSION_CONFIG_OPTION_PREFIX.length()), it.value] }
+ }
+
/**
* Factory method to construct an authentication configuration from the
* given properties.
diff --git a/src/main/groovy/org/ajoberstar/grgit/auth/JschAgentProxySessionFactory.groovy b/src/main/groovy/org/ajoberstar/grgit/auth/JschAgentProxySessionFactory.groovy
index c7fc1dbb..bfe81d8f 100644
--- a/src/main/groovy/org/ajoberstar/grgit/auth/JschAgentProxySessionFactory.groovy
+++ b/src/main/groovy/org/ajoberstar/grgit/auth/JschAgentProxySessionFactory.groovy
@@ -48,10 +48,10 @@ class JschAgentProxySessionFactory extends JschConfigSessionFactory {
}
/**
- * No actions performed by this.
+ * Customize session
*/
protected void configure(Host hc, Session session) {
- // no action
+ config.sessionConfig.each { key, value -> session.setConfig(key, value) }
}
/**
diff --git a/src/test/groovy/org/ajoberstar/grgit/auth/AuthConfigSpec.groovy b/src/test/groovy/org/ajoberstar/grgit/auth/AuthConfigSpec.groovy
index 01979aa2..63b9a868 100644
--- a/src/test/groovy/org/ajoberstar/grgit/auth/AuthConfigSpec.groovy
+++ b/src/test/groovy/org/ajoberstar/grgit/auth/AuthConfigSpec.groovy
@@ -69,4 +69,16 @@ class AuthConfigSpec extends Specification {
expect:
AuthConfig.fromMap([:]).getHardcodedCreds() == null
}
+
+ def 'getSessionConfig returns empty map if nothing specified'() {
+ expect:
+ AuthConfig.fromMap(Collections.emptyMap()).sessionConfig.isEmpty()
+ }
+
+ def 'getSessionConfig returns session config based on system property'() {
+ given:
+ System.setProperty(AuthConfig.SSH_SESSION_CONFIG_OPTION_PREFIX + 'StrictHostKeyChecking', 'no')
+ expect:
+ AuthConfig.fromMap(Collections.emptyMap()).sessionConfig == [ StrictHostKeyChecking: 'no' ]
+ }
}