git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Use SSH key from `GIT_SSH_KEY` variable if supplied

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 20, 2012, 01:55 UTC
Message-ID
<7vhaxk829x.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1332207557-10965-1-git-send-email-me@mmalecki.com>
Maciej Małecki <me@mmalecki.com> writes:
Show 15 quoted lines
>  	if (protocol == PROTO_SSH) {
> +		const char *key;
>  		const char *ssh = getenv("GIT_SSH");
>  		int putty = ssh && strcasestr(ssh, "plink");
>  		if (!ssh) ssh = "ssh";
> @@ -589,6 +590,13 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
>  			*arg++ = putty ? "-P" : "-p";
>  			*arg++ = port;
>  		}
> +
> +		key = getenv("GIT_SSH_KEY");
> +		if (key) {
> +			*arg++ = "-i";
> +			*arg++ = key;
> +		}
Hmm. I am somewhat torn.

The minimalist in me finds this extraneous and unnecessary noise. Why should the user always set GIT_SSH_KEY environment variable that only applies to git and does not help his other ssh sessions? Why isn't having an entry in .ssh/config to name IdentityFile sufficient?

On the other hand, the feature-creepist in me finds this somewhat lacking. Why should we give special treatment only to "-i $identity_file" option [*1*] and not others? Do we have to invent new environment variables if we wanted to pass "-c $cipher_spec", "-l $login_name", "-I $pkcs11", "-4", "-6", or "-b $bind_address"?

Would GIT_SSH_ARGS='-i /home/me/.ssh/there.pub -l me' be more appropriate?
[Footnote]

*1* In any case, GIT_SSH_KEY is misnamed. It should match whatever word ssh(1) uses to describe the concept--in this case, it is "identity file".

Previous: Maciej MałeckiNext: Robin H. Johnson
Message 2 of 4 in “Use SSH key from `GIT_SSH_KEY` variable if supplied”
  1. Use SSH key from `GIT_SSH_KEY` variable if suppliedMaciej Małecki, Mar 20, 2012
  2. Junio C HamanoMar 20, 2012
  3. Robin H. JohnsonMar 20, 2012
  4. Maciej MałeckiMar 20, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.