Skip to content

Commit 5fee949

Browse files
committed
configuration flag for StrictHostKeyChecking added
1 parent ea7372b commit 5fee949

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

spotless-changelog-lib/src/main/java/com/diffplug/spotless/changelog/GitActions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private void push(Consumer<PushCommand> cmd, RemoteRefUpdate.Status expected) th
133133
sshTransport.setSshSessionFactory(new JschConfigSessionFactory() {
134134
@Override
135135
protected void configure(OpenSshConfig.Host host, Session session) {
136-
session.setConfig("StrictHostKeyChecking", "no");
136+
session.setConfig("StrictHostKeyChecking", cfg.disableStrictHostKeyChecking ? "no" : "yes");
137137
}
138138
});
139139
});

spotless-changelog-lib/src/main/java/com/diffplug/spotless/changelog/GitCfg.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class GitCfg {
2929
public String commitMessage = "Published release/" + COMMIT_MESSAGE_VERSION;
3030
public String remote = "origin";
3131
public String branch = "main";
32+
public boolean disableStrictHostKeyChecking = false;
3233

3334
/** Returns an api configured with this config. */
3435
public GitActions withChangelog(File changelogFile, ChangelogAndNext model) throws IOException {

spotless-changelog-plugin-gradle/src/main/java/com/diffplug/spotless/changelog/gradle/ChangelogExtension.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,20 @@ public void setAppendDashSnapshotUnless_dashPrelease(boolean appendSnapshot) {
172172
}
173173
}
174174

175+
/**
176+
* If you set this to true, then the ssh host key checking over ssh:// remotes will be disabled.
177+
* By default strict host key checking is enabled. Make sure that there is an entry
178+
* in the know_hosts file for given ssh remote.
179+
* You can add `-PsshDisableStrictHostKeyChecking=true` to the gradle command.
180+
* Note: this command line parameter overrides buildscript setting.
181+
* In your buildscript you can disable checking with `sshDisableStrictHostKeyChecking = true`
182+
*/
183+
public void setSshDisableStrictHostKeyChecking(boolean disableStrictHostKeyChecking) {
184+
gitCfg.disableStrictHostKeyChecking = project.getRootProject().hasProperty("sshDisableStrictHostKeyChecking")
185+
? Boolean.parseBoolean((String) project.getRootProject().property("sshDisableStrictHostKeyChecking"))
186+
: disableStrictHostKeyChecking;
187+
}
188+
175189
// tag and push
176190
/** Default value is `release/` */
177191
public void tagPrefix(String tagPrefix) {

0 commit comments

Comments
 (0)