{"thread":{"id":"2730","subject":"How can I specify a non-standard TCP port for a git+ssh connection?","startedAt":"2005-12-02T12:48:01Z","lastAt":"2005-12-02T16:07:33Z","messageCount":2,"participants":["Andreas Jochens","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"13104","messageId":"20051202124801.GA20332@andaco.de","threadId":"2730","inReplyTo":null,"subject":"How can I specify a non-standard TCP port for a git+ssh connection?","fromName":"Andreas Jochens","fromEmail":"aj@andaco.de","sentAt":"2005-12-02T12:48:01Z","receivedAt":"2005-12-02T12:48:01Z","isPatch":false,"sender":{"key":"aj@andaco.de","avatar":null},"body":"Hello,\n\nis there a simple way to specify a non-standard TCP port for a git+ssh\nconnection? \n\nThe following small patch would allow to use an URL like \n'git+ssh://user@hostname:port/path' to specify an arbitrary \nport for the ssh connection.\n\nRegards\nAndreas Jochens\n\n connect.c |   12 ++++++++++--\n 1 files changed, 10 insertions(+), 2 deletions(-)\n\ndiff --git a/connect.c b/connect.c\nindex 93f6f80..4b640dd 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -560,7 +560,7 @@ static int git_proxy_connect(int fd[2], \n int git_connect(int fd[2], char *url, const char *prog)\n {\n \tchar command[1024];\n-\tchar *host, *path = url;\n+\tchar *host, *port = NULL, *path = url;\n \tchar *colon = NULL;\n \tint pipefd[2][2];\n \tpid_t pid;\n@@ -597,6 +597,10 @@ int git_connect(int fd[2], char *url, co\n \t\t\tpath = strdup(ptr);\n \n \t\t*ptr = '\\0';\n+\t\tif ((colon = strchr(host, ':'))) {\n+\t\t\t*colon = '\\0';\n+\t\t\tport = colon + 1;\n+\t\t}\n \t}\n \n \tif (protocol == PROTO_GIT) {\n@@ -626,7 +630,11 @@ int git_connect(int fd[2], char *url, co\n \t\t\t\tssh_basename = ssh;\n \t\t\telse\n \t\t\t\tssh_basename++;\n-\t\t\texeclp(ssh, ssh_basename, host, command, NULL);\n+\t\t\tif (port)\n+\t\t\t\texeclp(ssh, ssh_basename, \"-p\", port, host, \n+\t\t\t\t       command, NULL);\n+\t\t\telse\n+\t\t\t\texeclp(ssh, ssh_basename, host, command, NULL);\n \t\t}\n \t\telse\n \t\t\texeclp(\"sh\", \"sh\", \"-c\", command, NULL);\n"},{"id":"13108","messageId":"Pine.LNX.4.64.0512020805480.3099@g5.osdl.org","threadId":"2730","inReplyTo":"20051202124801.GA20332@andaco.de","subject":"Re: How can I specify a non-standard TCP port for a git+ssh connection?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-12-02T16:07:33Z","receivedAt":"2005-12-02T16:07:33Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 2 Dec 2005, Andreas Jochens wrote:\n> \n> is there a simple way to specify a non-standard TCP port for a git+ssh\n> connection? \n\nUse the \".ssh/config\" file ;)\n\n> The following small patch would allow to use an URL like \n> 'git+ssh://user@hostname:port/path' to specify an arbitrary \n> port for the ssh connection.\n\nMaybe. On the other hand, I think we'd be better off  with perhaps some \nway to just specify arbitrary options to the \"ssh\" program. Sometimes you \nmight want to specify identity-files etc too.\n\n\t\tLinus\n"}]}