1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 01:18:00 +00:00

Document how to set GIT_SSH_COMMAND to plink -batch.

A user helpfully figured this out for us after the changes to Plink's
password prompt handling had disrupted their previous workflow. So it
seems worth documenting in case anyone else needs this fix.

(I think it is a fix, not a workaround: anyone needing this option now
probably _should_ have been doing it all along, because with the old
behaviour, Plink would have been sending a password prompt to Git, and
maybe even interpreting some of Git's protocol output as a password!
-batch would have been a more sensible way to abort the connection
even before the changes.)
This commit is contained in:
Simon Tatham 2024-12-15 09:59:22 +00:00
parent 09095a7d92
commit 7802932eed

View File

@ -243,6 +243,10 @@ This may help Plink's behaviour when it is used in automated
scripts: using \c{-batch}, if something goes wrong at connection
time, the batch job will fail rather than hang.
If another program is invoking Plink on your behalf, then you might
need to arrange that that program passes \c{-batch} to Plink. See
\k{plink-git} for an example involving Git.
\S2{plink-option-s} \I{-s-plink}\c{-s}: remote command is SSH subsystem
If you specify the \c{-s} option, Plink passes the specified command
@ -395,6 +399,38 @@ particular web area:
Any non-interactive command you could usefully run on the server
command line, you can run in a batch file using Plink in this way.
\H{plink-git} Using Plink with \i{Git}
To use Plink for Git operations performed over SSH, you can set the
environment variable \i\c{GIT_SSH_COMMAND} to point to Plink.
For example, if you've run PuTTY's full Windows installer and it has
installed Plink in the default location, you might do this:
\c set GIT_SSH_COMMAND="C:\Program Files\PuTTY\plink.exe"
or if you've put Plink somewhere else then you can do a similar thing
with a different path.
This environment variable accepts a whole command line, not just an
executable file name. So you can add Plink options to the end of it if
you like. For example, if you're using Git in a batch-mode context,
where your Git jobs are running unattended and nobody is available to
answer interactive prompts, you might also append the \cq{-batch}
option (\k{plink-option-batch}):
\c set GIT_SSH_COMMAND="C:\Program Files\PuTTY\plink.exe" -batch
and then if Plink unexpectedly prints a prompt of some kind (for
example, because the SSH server's host key has changed), your batch
job will terminate with an error message, instead of stopping and
waiting for user input that will never arrive.
(However, you don't \e{always} want to do this with Git. If you're
using Git interactively, you might \e{want} Plink to stop for
interactive prompts \dash for example, to let you enter a password for
the SSH server.)
\H{plink-cvs} Using Plink with \i{CVS}
To use Plink with CVS, you need to set the environment variable