Skip to content

Commit 9ae13ae

Browse files
Enhance SSH command options for improved security by adding BatchMode and disabling PasswordAuthentication
1 parent 072d879 commit 9ae13ae

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,7 +2725,8 @@ Path createWindowsGitSSH(Path key, String user, Path knownHosts) throws IOExcept
27252725
w.write("setlocal enabledelayedexpansion");
27262726
w.newLine();
27272727
w.write("\"" + sshexe.getAbsolutePath()
2728-
+ "\" -i \"!JENKINS_GIT_SSH_KEYFILE!\" -l \"!JENKINS_GIT_SSH_USERNAME!\" "
2728+
+ "\" -T -i \"!JENKINS_GIT_SSH_KEYFILE!\" -l \"!JENKINS_GIT_SSH_USERNAME!\" "
2729+
+ "-o BatchMode=yes -o PasswordAuthentication=no "
27292730
+ getHostKeyFactory().forCliGit(listener).getVerifyHostKeyOption(knownHosts) + " %* ");
27302731
w.newLine();
27312732
}
@@ -2748,7 +2749,8 @@ Path createUnixGitSSH(Path key, String user, Path knownHosts) throws IOException
27482749
w.newLine();
27492750
w.write("fi");
27502751
w.newLine();
2751-
w.write("ssh -i \"$JENKINS_GIT_SSH_KEYFILE\" -l \"$JENKINS_GIT_SSH_USERNAME\" "
2752+
w.write("ssh -T -i \"$JENKINS_GIT_SSH_KEYFILE\" -l \"$JENKINS_GIT_SSH_USERNAME\" "
2753+
+ "-o BatchMode=yes -o PasswordAuthentication=no "
27522754
+ getHostKeyFactory().forCliGit(listener).getVerifyHostKeyOption(knownHosts) + " \"$@\"");
27532755
w.newLine();
27542756
}

0 commit comments

Comments
 (0)