{"thread":{"id":"30002","subject":"[PATCH] Use SSH key from `GIT_SSH_KEY` variable if supplied","startedAt":"2012-03-20T01:39:17Z","lastAt":"2012-03-20T08:07:47Z","messageCount":4,"participants":["Maciej Małecki","Junio C Hamano","Robin H. Johnson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"187296","messageId":"1332207557-10965-1-git-send-email-me@mmalecki.com","threadId":"30002","inReplyTo":null,"subject":"[PATCH] Use SSH key from `GIT_SSH_KEY` variable if supplied","fromName":"Maciej Małecki","fromEmail":"me@mmalecki.com","sentAt":"2012-03-20T01:39:17Z","receivedAt":"2012-03-20T01:39:17Z","isPatch":true,"sender":{"key":"me@mmalecki.com","avatar":null},"body":"Using a different SSH key for various SSH commands seems to be a\nrecurring theme. Allow user to supply path to the SSH key he wants to\nuse for operations that require it without need to use `GIT_SSH`\nvariable and a wrapper script.\n\nSigned-off-by: Maciej Małecki <me@mmalecki.com>\n---\n connect.c |   10 +++++++++-\n 1 files changed, 9 insertions(+), 1 deletions(-)\n\ndiff --git a/connect.c b/connect.c\nindex 912cdde..dd3489d 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -575,8 +575,9 @@ struct child_process *git_connect(int fd[2], const char *url_orig,\n \t\tdie(\"command line too long\");\n \n \tconn->in = conn->out = -1;\n-\tconn->argv = arg = xcalloc(7, sizeof(*arg));\n+\tconn->argv = arg = xcalloc(9, sizeof(*arg));\n \tif (protocol == PROTO_SSH) {\n+\t\tconst char *key;\n \t\tconst char *ssh = getenv(\"GIT_SSH\");\n \t\tint putty = ssh && strcasestr(ssh, \"plink\");\n \t\tif (!ssh) ssh = \"ssh\";\n@@ -589,6 +590,13 @@ struct child_process *git_connect(int fd[2], const char *url_orig,\n \t\t\t*arg++ = putty ? \"-P\" : \"-p\";\n \t\t\t*arg++ = port;\n \t\t}\n+\n+\t\tkey = getenv(\"GIT_SSH_KEY\");\n+\t\tif (key) {\n+\t\t\t*arg++ = \"-i\";\n+\t\t\t*arg++ = key;\n+\t\t}\n+\n \t\t*arg++ = host;\n \t}\n \telse {\n-- \n1.7.7.4\n"},{"id":"187297","messageId":"7vhaxk829x.fsf@alter.siamese.dyndns.org","threadId":"30002","inReplyTo":"1332207557-10965-1-git-send-email-me@mmalecki.com","subject":"Re: [PATCH] Use SSH key from `GIT_SSH_KEY` variable if supplied","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-03-20T01:55:06Z","receivedAt":"2012-03-20T01:55:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Maciej Małecki <me@mmalecki.com> writes:\n\n>  \tif (protocol == PROTO_SSH) {\n> +\t\tconst char *key;\n>  \t\tconst char *ssh = getenv(\"GIT_SSH\");\n>  \t\tint putty = ssh && strcasestr(ssh, \"plink\");\n>  \t\tif (!ssh) ssh = \"ssh\";\n> @@ -589,6 +590,13 @@ struct child_process *git_connect(int fd[2], const char *url_orig,\n>  \t\t\t*arg++ = putty ? \"-P\" : \"-p\";\n>  \t\t\t*arg++ = port;\n>  \t\t}\n> +\n> +\t\tkey = getenv(\"GIT_SSH_KEY\");\n> +\t\tif (key) {\n> +\t\t\t*arg++ = \"-i\";\n> +\t\t\t*arg++ = key;\n> +\t\t}\n\nHmm. I am somewhat torn.\n\nThe minimalist in me finds this extraneous and unnecessary noise.  Why\nshould the user always set GIT_SSH_KEY environment variable that only\napplies to git and does not help his other ssh sessions?  Why isn't having\nan entry in .ssh/config to name IdentityFile sufficient?\n\nOn the other hand, the feature-creepist in me finds this somewhat lacking.\nWhy should we give special treatment only to \"-i $identity_file\" option\n[*1*] and not others?  Do we have to invent new environment variables if\nwe wanted to pass \"-c $cipher_spec\", \"-l $login_name\", \"-I $pkcs11\", \"-4\",\n\"-6\", or \"-b $bind_address\"?\n\nWould GIT_SSH_ARGS='-i /home/me/.ssh/there.pub -l me' be more appropriate?\n\n\n[Footnote]\n\n*1* In any case, GIT_SSH_KEY is misnamed.  It should match whatever word\nssh(1) uses to describe the concept--in this case, it is \"identity file\".\n"},{"id":"187298","messageId":"robbat2-20120320T020552-803311730Z@orbis-terrarum.net","threadId":"30002","inReplyTo":"7vhaxk829x.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Use SSH key from `GIT_SSH_KEY` variable if supplied","fromName":"Robin H. Johnson","fromEmail":"robbat2@gentoo.org","sentAt":"2012-03-20T02:07:11Z","receivedAt":"2012-03-20T02:07:11Z","isPatch":true,"sender":{"key":"robbat2@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/373898?v=4"},"body":"On Mon, Mar 19, 2012 at 06:55:06PM -0700,  Junio C Hamano wrote:\n> Hmm. I am somewhat torn.\n> \n> The minimalist in me finds this extraneous and unnecessary noise.  Why\n> should the user always set GIT_SSH_KEY environment variable that only\n> applies to git and does not help his other ssh sessions?  Why isn't having\n> an entry in .ssh/config to name IdentityFile sufficient?\n> \n> Would GIT_SSH_ARGS='-i /home/me/.ssh/there.pub -l me' be more appropriate?\nI'd strongly prefer a generic args support, for making it easier to use\nin deployment code.\n\n-- \nRobin Hugh Johnson\nGentoo Linux: Developer, Trustee & Infrastructure Lead\nE-Mail     : robbat2@gentoo.org\nGnuPG FP   : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85\n"},{"id":"187310","messageId":"CAKC8-7zr8JKCzMwameXvXVhCcycNG8B-dzCcPiCxrqFzGr_b8w@mail.gmail.com","threadId":"30002","inReplyTo":"robbat2-20120320T020552-803311730Z@orbis-terrarum.net","subject":"Re: [PATCH] Use SSH key from `GIT_SSH_KEY` variable if supplied","fromName":"Maciej Małecki","fromEmail":"me@mmalecki.com","sentAt":"2012-03-20T08:07:47Z","receivedAt":"2012-03-20T08:07:47Z","isPatch":true,"sender":{"key":"me@mmalecki.com","avatar":null},"body":"W dniu 20 marca 2012 03:07 użytkownik Robin H. Johnson\n<robbat2@gentoo.org> napisał:\n> On Mon, Mar 19, 2012 at 06:55:06PM -0700,  Junio C Hamano wrote:\n>> Hmm. I am somewhat torn.\n>>\n>> The minimalist in me finds this extraneous and unnecessary noise.  Why\n>> should the user always set GIT_SSH_KEY environment variable that only\n>> applies to git and does not help his other ssh sessions?  Why isn't having\n>> an entry in .ssh/config to name IdentityFile sufficient?\n>>\n>> Would GIT_SSH_ARGS='-i /home/me/.ssh/there.pub -l me' be more appropriate?\n> I'd strongly prefer a generic args support, for making it easier to use\n> in deployment code.\nAfter rethinking it, I'm also +1 on GIT_SSH_ARGS. Should I submit a patch?\nSorry for noob question, but it'd go into a new e-mail thread, right?\n"}]}