Skip to content

Commit 36ad53f

Browse files
Edward Z. Yanggitster
authored andcommitted
connect.c: Support PuTTY plink and TortoisePlink as SSH on Windows
OpenSSH uses -p to specify custom ports, while PuTTY plink and TortoisePlink use -P. Git now detects if plink is in GIT_SSH and modify its flags as necessary. We call plink with -batch, so that it will error out with an error message instead of waiting for user input. As reported in msysGit issue 96, plink wants to interact with the user asking if a host key should be accepted, but this just blocks the terminal, since plink tries to get the answer from stdin. However, stdin is already connected to Git that wants to send input to the remote command. But we do not pass -batch to TortoisePlink, because TortoisePlink uses a GUI to communicate with the user, and it does not understand -batch. Signed-off-by: Edward Z. Yang <[email protected]> Signed-off-by: Steffen Prohaska <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7b66da2 commit 36ad53f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

connect.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,14 +602,18 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
602602
die("command line too long");
603603

604604
conn->in = conn->out = -1;
605-
conn->argv = arg = xcalloc(6, sizeof(*arg));
605+
conn->argv = arg = xcalloc(7, sizeof(*arg));
606606
if (protocol == PROTO_SSH) {
607607
const char *ssh = getenv("GIT_SSH");
608+
int putty = ssh && strcasestr(ssh, "plink");
608609
if (!ssh) ssh = "ssh";
609610

610611
*arg++ = ssh;
612+
if (putty && !strcasestr(ssh, "tortoiseplink"))
613+
*arg++ = "-batch";
611614
if (port) {
612-
*arg++ = "-p";
615+
/* P is for PuTTY, p is for OpenSSH */
616+
*arg++ = putty ? "-P" : "-p";
613617
*arg++ = port;
614618
}
615619
*arg++ = host;

0 commit comments

Comments
 (0)