* How can I specify a non-standard TCP port for a git+ssh connection?
@ 2005-12-02 12:48 Andreas Jochens
2005-12-02 16:07 ` Linus Torvalds
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Jochens @ 2005-12-02 12:48 UTC (permalink / raw)
To: git
Hello,
is there a simple way to specify a non-standard TCP port for a git+ssh
connection?
The following small patch would allow to use an URL like
'git+ssh://user@hostname:port/path' to specify an arbitrary
port for the ssh connection.
Regards
Andreas Jochens
connect.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/connect.c b/connect.c
index 93f6f80..4b640dd 100644
--- a/connect.c
+++ b/connect.c
@@ -560,7 +560,7 @@ static int git_proxy_connect(int fd[2],
int git_connect(int fd[2], char *url, const char *prog)
{
char command[1024];
- char *host, *path = url;
+ char *host, *port = NULL, *path = url;
char *colon = NULL;
int pipefd[2][2];
pid_t pid;
@@ -597,6 +597,10 @@ int git_connect(int fd[2], char *url, co
path = strdup(ptr);
*ptr = '\0';
+ if ((colon = strchr(host, ':'))) {
+ *colon = '\0';
+ port = colon + 1;
+ }
}
if (protocol == PROTO_GIT) {
@@ -626,7 +630,11 @@ int git_connect(int fd[2], char *url, co
ssh_basename = ssh;
else
ssh_basename++;
- execlp(ssh, ssh_basename, host, command, NULL);
+ if (port)
+ execlp(ssh, ssh_basename, "-p", port, host,
+ command, NULL);
+ else
+ execlp(ssh, ssh_basename, host, command, NULL);
}
else
execlp("sh", "sh", "-c", command, NULL);
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: How can I specify a non-standard TCP port for a git+ssh connection?
2005-12-02 12:48 How can I specify a non-standard TCP port for a git+ssh connection? Andreas Jochens
@ 2005-12-02 16:07 ` Linus Torvalds
0 siblings, 0 replies; 6+ messages in thread
From: Linus Torvalds @ 2005-12-02 16:07 UTC (permalink / raw)
To: Andreas Jochens; +Cc: git
On Fri, 2 Dec 2005, Andreas Jochens wrote:
>
> is there a simple way to specify a non-standard TCP port for a git+ssh
> connection?
Use the ".ssh/config" file ;)
> The following small patch would allow to use an URL like
> 'git+ssh://user@hostname:port/path' to specify an arbitrary
> port for the ssh connection.
Maybe. On the other hand, I think we'd be better off with perhaps some
way to just specify arbitrary options to the "ssh" program. Sometimes you
might want to specify identity-files etc too.
Linus
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How can I specify a non-standard TCP port for a git+ssh connection?
@ 2005-12-02 19:31 linux
2005-12-03 8:06 ` Andreas Jochens
0 siblings, 1 reply; 6+ messages in thread
From: linux @ 2005-12-02 19:31 UTC (permalink / raw)
To: aj, git, torvalds
Actually, you don't need any git support. ssh allows you to set up
"virtual hosts" with any combination of options you like.
Host <virtual>
HostName <physical>
Port <nonstandard>
User <whoever>
IdentityFile <custom>
ForwardAgent no
So typing "ssh <virtual>" will have the effect of
ssh <whoever>@<physical> -p <nonstandard> -i <custom> -a
Quite often, you let <virtual> == <physical>, so it's "custom settings
for talking to this host", but you can have multiple different virtual
names that all map to the same physical host.
But the point is that as long as you can pass a hostname through to ssh,
you can carry as many custom settings as you like with it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How can I specify a non-standard TCP port for a git+ssh connection?
2005-12-02 19:31 linux
@ 2005-12-03 8:06 ` Andreas Jochens
2005-12-03 19:09 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Jochens @ 2005-12-03 8:06 UTC (permalink / raw)
To: linux; +Cc: git, torvalds
On 05-Dec-02 14:31, linux@horizon.com wrote:
> Actually, you don't need any git support. ssh allows you to set up
> "virtual hosts" with any combination of options you like.
> So typing "ssh <virtual>" will have the effect of
> ssh <whoever>@<physical> -p <nonstandard> -i <custom> -a
This is a nice feature, of course. But I still have to edit a separate
config file. In some cases (e.g. scripts using ad hoc port forwarding) it
would be much easier if the non-standard port and maybe some other
options could be specified directly on the git command line or
in .git/branches.
Regards
Andreas Jochens
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How can I specify a non-standard TCP port for a git+ssh connection?
2005-12-03 8:06 ` Andreas Jochens
@ 2005-12-03 19:09 ` Junio C Hamano
2005-12-03 21:43 ` Andreas Jochens
0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2005-12-03 19:09 UTC (permalink / raw)
To: Andreas Jochens; +Cc: git
Andreas Jochens <aj@andaco.de> writes:
> This is a nice feature, of course. But I still have to edit a separate
> config file. In some cases (e.g. scripts using ad hoc port forwarding) it
> would be much easier if the non-standard port and maybe some other
> options could be specified directly on the git command line or
Having something on the command line to make it easy to override
one-shot you might be able to talk me into, but not in a config
file for git; there is a standard place to hold ssh
configuration already.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How can I specify a non-standard TCP port for a git+ssh connection?
2005-12-03 19:09 ` Junio C Hamano
@ 2005-12-03 21:43 ` Andreas Jochens
0 siblings, 0 replies; 6+ messages in thread
From: Andreas Jochens @ 2005-12-03 21:43 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On 05-Dec-03 11:09, Junio C Hamano wrote:
> Having something on the command line to make it easy to override
> one-shot you might be able to talk me into, but not in a config
> file for git; there is a standard place to hold ssh
> configuration already.
You are right, a duplication of ssh config file options in git
config files should not be necessary.
A way to specify a non-standard port for ssh on the command line
would be sufficient. It is possible to specify non-standard
ports for the git, http and rsync protocols on the command line.
Why not for ssh?
Regards
Andreas Jochens
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-12-03 21:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-02 12:48 How can I specify a non-standard TCP port for a git+ssh connection? Andreas Jochens
2005-12-02 16:07 ` Linus Torvalds
-- strict thread matches above, loose matches on Subject: below --
2005-12-02 19:31 linux
2005-12-03 8:06 ` Andreas Jochens
2005-12-03 19:09 ` Junio C Hamano
2005-12-03 21:43 ` Andreas Jochens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).