{"thread":{"id":"1407","subject":"[PATCH] GIT_SSH alternate ssh name or helper","startedAt":"2005-08-03T15:15:42Z","lastAt":"2005-08-03T19:29:55Z","messageCount":4,"participants":["Martin Sivak","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"6752","messageId":"20050803151542.GA6655@medusa","threadId":"1407","inReplyTo":null,"subject":"[PATCH] GIT_SSH alternate ssh name or helper","fromName":"Martin Sivak","fromEmail":"mars@nomi.cz","sentAt":"2005-08-03T15:15:42Z","receivedAt":"2005-08-03T15:15:42Z","isPatch":true,"sender":{"key":"mars@nomi.cz","avatar":null},"body":"This patch make possible to use alternate ssh binary or ssh helper\nscript. The script can be used to give additional parameters to ssh\nbinary (like private key, protocol version, ...).\n\nExample script could look like this:\n\n#!/bin/sh\nssh -1 -i myprivatekey.key \"$@\"\n\nThe patch itself is realy very simple:\n\ndiff -uNr git-current/connect.c git-current-mars@nomi.cz/connect.c\n--- git-current/connect.c  2005-08-03 15:00:04.000000000 +0200\n+++ git-current-mars@nomi.cz/connect.c 2005-08-03 16:32:36.000000000 +0200\n@@ -166,6 +166,9 @@\n   int pipefd[2][2];\n   pid_t pid;\n   enum protocol protocol;\n+  char *sshprog;\n+\n+  sshprog = getenv(\"GIT_SSH\") ? : \"ssh\";\n\n   host = NULL;\n   path = url;\n@@ -205,7 +208,7 @@\n      close(pipefd[1][0]);\n      close(pipefd[1][1]);\n      if (protocol == PROTO_SSH)\n-        execlp(\"ssh\", \"ssh\", host, command, NULL);\n+        execlp(sshprog, \"ssh\", host, command, NULL);\n      else\n         execlp(\"sh\", \"sh\", \"-c\", command, NULL);\n      die(\"exec failed\");\ndiff -uNr git-current/rsh.c git-current-mars@nomi.cz/rsh.c\n--- git-current/rsh.c   2005-08-03 15:00:04.000000000 +0200\n+++ git-current-mars@nomi.cz/rsh.c  2005-08-03 16:26:39.000000000 +0200\n@@ -17,6 +17,7 @@\n   char command[COMMAND_SIZE];\n   char *posn;\n   int i;\n+  char *prog; \n\n   if (!strcmp(url, \"-\")) {\n      *fd_in = 0;\n@@ -24,6 +25,8 @@\n      return 0;\n   }\n\n+  prog = getenv(\"GIT_SSH\") ? : \"ssh\";\n+  \n   host = strstr(url, \"//\");\n   if (host) {\n      host += 2;\n@@ -59,7 +62,7 @@\n      close(sv[1]);\n      dup2(sv[0], 0);\n      dup2(sv[0], 1);\n-     execlp(\"ssh\", \"ssh\", host, command, NULL);\n+     execlp(prog, \"ssh\", host, command, NULL);\n   }\n   close(sv[0]);\n   *fd_in = sv[1];\n\n\nSigned-off-by: Martin Sivak <mars@nomi.cz>\n\n-- \nMartin Sivak\nmars@nomi.cz\n\n"},{"id":"6762","messageId":"7viryndjvu.fsf@assigned-by-dhcp.cox.net","threadId":"1407","inReplyTo":"20050803151542.GA6655@medusa","subject":"Re: [PATCH] GIT_SSH alternate ssh name or helper","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-08-03T17:12:53Z","receivedAt":"2005-08-03T17:12:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Sivak <mars@nomi.cz> writes:\n\n> This patch make possible to use alternate ssh binary or ssh helper\n> script. The script can be used to give additional parameters to ssh\n> binary (like private key, protocol version, ...).\n>\n> Example script could look like this:\n>\n> #!/bin/sh\n> ssh -1 -i myprivatekey.key \"$@\"\n>\n> The patch itself is realy very simple:\n\nI understand why you would want this if your ssh binary is\ncalled something other than ssh [*1*], but I doubt the example\nyou gave needs this patch.  Could you explain why having\nsomething like this in your .ssh/config file is not enough?\n\n    Host foo.bar.xz\n      Protocol 1\n      IdentityFile ~/.ssh/privatekey.key\n\nEven if you wish to use different settings between git and\ninteractive, I presume you could do something like this:\n\n    # for interactive\n    Host foo.bar.xz\n      Protocol 2\n\n    # real repo is foo.bar.xz:/pub/scm/git/git.git/ but pull with\n    # git-foo.bar.xz:/pub/scm/git/git.git/\n    Host git-foo.bar.xz\n      Hostname foo.bar.xz\n      Protocol 1\n      IdentityFile ~/.ssh/privatekey.key\n\n\n[Footnote]\n*1* and even in that case you can trivially fix it by having\na small wrapper in $HOME/bin/ssh:\n\n    #!/bin/sh\n    exec ssh-installed-under-nonstandard-name \"$@\"\n"},{"id":"6776","messageId":"20050803185621.GA20645@medusa","threadId":"1407","inReplyTo":"7viryndjvu.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] GIT_SSH alternate ssh name or helper","fromName":"Martin Sivak","fromEmail":"mars@nomi.cz","sentAt":"2005-08-03T18:56:21Z","receivedAt":"2005-08-03T18:56:21Z","isPatch":true,"sender":{"key":"mars@nomi.cz","avatar":null},"body":"> I understand why you would want this if your ssh binary is\n> called something other than ssh [*1*], but I doubt the example\n> you gave needs this patch.  Could you explain why having\n> something like this in your .ssh/config file is not enough?\n> \n>     Host foo.bar.xz\n>       Protocol 1\n>       IdentityFile ~/.ssh/privatekey.key\n\nThe example was of course about the simpliest thing i thought of.\n\nI would find that variable (GIT_SSH) usefull, and actually it does no\nharm, because you already have GIT_SSH_PULL & PUSH variables, for the\nsame purpose (to define different name).\n\nActually I think there is at least one case, when helper script is useful.\nI mean, how would you setup different identities for more user accounts on the\nsame server (it doesn't happen often, but..)?\n\nBest regards\n--\nMartin Sivak\nmars@nomi.cz\n\n"},{"id":"6778","messageId":"7v4qa6akek.fsf@assigned-by-dhcp.cox.net","threadId":"1407","inReplyTo":"20050803185621.GA20645@medusa","subject":"Re: [PATCH] GIT_SSH alternate ssh name or helper","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-08-03T19:29:55Z","receivedAt":"2005-08-03T19:29:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Sivak <mars@nomi.cz> writes:\n\n> I mean, how would you setup different identities for more user\n> accounts on the same server (it doesn't happen often, but..)?\n\nI do not claim the way I do is the best way, but I do that all\nthe time.\n\nI just use different \"name\" to connect, by setting up the ssh\nclient configuration file to give me the protocol parameters I\nwant depending on the name I use.  The wildcard support handles\npermutations quite nicely.  Something like this:\n\n    $ cat .ssh/config\n    Host *-1-*\n      Protocol 1\n    Host *-2-*\n      Protocol 2\n    Host lucia-*\n      Hostname lucia.example.xz\n    Host myriam-*\n      Hostname myriam.example.xz\n    Host *-junio\n      IdentityFile ~/.ssh/identity-junio\n      IdentityFile ~/.ssh/id_dsa-junio\n    Host *-junkio\n      IdentityFile ~/.ssh/identity-junkio\n      IdentityFile ~/.ssh/id_dsa-junkio\n\n    $ ssh lucia-2-junio ;# go to lucia over protocol 2, use id_dsa-junio\n    $ ssh myriam-1-junkio ;# to myriam over protocol 1, use identity-junkio\n"}]}