Merge branch 'tq/git-ssh-command'
Allow passing extra set of arguments when ssh is invoked to create an encrypted & authenticated connection by introducing a new environment variable GIT_SSH_COMMAND, whose contents is interpreted by shells. This is not possible with existing GIT_SSH mechanism whose invocation bypasses shells, which was designed more to match what other programs with similar variables did, not necessarily to be more useful. * tq/git-ssh-command: git_connect: set ssh shell command in GIT_SSH_COMMAND
This commit is contained in:
commit
09d60d785c
@ -881,19 +881,21 @@ other
|
|||||||
and the `core.editor` option in linkgit:git-config[1].
|
and the `core.editor` option in linkgit:git-config[1].
|
||||||
|
|
||||||
'GIT_SSH'::
|
'GIT_SSH'::
|
||||||
If this environment variable is set then 'git fetch'
|
'GIT_SSH_COMMAND'::
|
||||||
and 'git push' will use this command instead
|
If either of these environment variables is set then 'git fetch'
|
||||||
of 'ssh' when they need to connect to a remote system.
|
and 'git push' will use the specified command instead of 'ssh'
|
||||||
The '$GIT_SSH' command will be given exactly two or
|
when they need to connect to a remote system.
|
||||||
four arguments: the 'username@host' (or just 'host')
|
The command will be given exactly two or four arguments: the
|
||||||
from the URL and the shell command to execute on that
|
'username@host' (or just 'host') from the URL and the shell
|
||||||
remote system, optionally preceded by '-p' (literally) and
|
command to execute on that remote system, optionally preceded by
|
||||||
the 'port' from the URL when it specifies something other
|
'-p' (literally) and the 'port' from the URL when it specifies
|
||||||
than the default SSH port.
|
something other than the default SSH port.
|
||||||
+
|
+
|
||||||
To pass options to the program that you want to list in GIT_SSH
|
`$GIT_SSH_COMMAND` takes precedence over `$GIT_SSH`, and is interpreted
|
||||||
you will need to wrap the program and options into a shell script,
|
by the shell, which allows additional arguments to be included.
|
||||||
then set GIT_SSH to refer to the shell script.
|
`$GIT_SSH` on the other hand must be just the path to a program
|
||||||
|
(which can be a wrapper shell script, if additional arguments are
|
||||||
|
needed).
|
||||||
+
|
+
|
||||||
Usually it is easier to configure any desired options through your
|
Usually it is easier to configure any desired options through your
|
||||||
personal `.ssh/config` file. Please consult your ssh documentation
|
personal `.ssh/config` file. Please consult your ssh documentation
|
||||||
|
15
connect.c
15
connect.c
@ -700,14 +700,23 @@ struct child_process *git_connect(int fd[2], const char *url,
|
|||||||
|
|
||||||
conn->in = conn->out = -1;
|
conn->in = conn->out = -1;
|
||||||
if (protocol == PROTO_SSH) {
|
if (protocol == PROTO_SSH) {
|
||||||
const char *ssh = getenv("GIT_SSH");
|
const char *ssh;
|
||||||
int putty = ssh && strcasestr(ssh, "plink");
|
int putty;
|
||||||
char *ssh_host = hostandport;
|
char *ssh_host = hostandport;
|
||||||
const char *port = NULL;
|
const char *port = NULL;
|
||||||
get_host_and_port(&ssh_host, &port);
|
get_host_and_port(&ssh_host, &port);
|
||||||
port = get_port_numeric(port);
|
port = get_port_numeric(port);
|
||||||
|
|
||||||
if (!ssh) ssh = "ssh";
|
ssh = getenv("GIT_SSH_COMMAND");
|
||||||
|
if (ssh) {
|
||||||
|
conn->use_shell = 1;
|
||||||
|
putty = 0;
|
||||||
|
} else {
|
||||||
|
ssh = getenv("GIT_SSH");
|
||||||
|
if (!ssh)
|
||||||
|
ssh = "ssh";
|
||||||
|
putty = !!strcasestr(ssh, "plink");
|
||||||
|
}
|
||||||
|
|
||||||
argv_array_push(&conn->args, ssh);
|
argv_array_push(&conn->args, ssh);
|
||||||
if (putty && !strcasestr(ssh, "tortoiseplink"))
|
if (putty && !strcasestr(ssh, "tortoiseplink"))
|
||||||
|
Loading…
Reference in New Issue
Block a user