Using a non-standard ssh port

6,877 views
Skip to first unread message

G Drukier

unread,
Nov 10, 2010, 9:53:12 AM11/10/10
to gito...@googlegroups.com
My remote repositories are on a machine sitting behind a firewall. The
standard ssh port is already being forwarded elsewhere, so ssh on this
machine needs to be listening on another port. In issuing the git
commands, is it possible to specify the port on the the remote target?
I've tried several variants like:

> git clone -p 2222 git@server:repo
> git clone "-p 2222 git@server":repo
> git clone "git@server:2222":repo
> git clone "git@server -p 2222":repo

but none of these work. Either git complains about the unknown -p
flag, or ssh is done to port 22 as usual.

N.B. > ssh -p 2222 git@server does get me gitolite version (v1.5.7-2-
g182b1d0) and access information, so it's there.


Kevin P. Fleming

unread,
Nov 10, 2010, 9:58:02 AM11/10/10
to gito...@googlegroups.com
On 11/10/2010 08:53 AM, G Drukier wrote:
> My remote repositories are on a machine sitting behind a firewall. The
> standard ssh port is already being forwarded elsewhere, so ssh on this
> machine needs to be listening on another port. In issuing the git
> commands, is it possible to specify the port on the the remote target?
> I've tried several variants like:
>
>> git clone -p 2222 git@server:repo
>> git clone "-p 2222 git@server":repo
>> git clone "git@server:2222":repo
>> git clone "git@server -p 2222":repo

You need to use the explicit SSH protocol URL syntax for git:

git clone ssh://git@server:2222/repo

--
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
skype: kpfleming | jabber: kfle...@digium.com
Check us out at www.digium.com & www.asterisk.org

Paweł Zuzelski

unread,
Nov 10, 2010, 10:23:39 AM11/10/10
to G Drukier, gito...@googlegroups.com

Just specify this port in your ssh client config (~/.ssh/config).
Add such entry:

Host server
User git
Port 2222

Now you can use just: ssh://server.

It will work for any program using ssh (ssh, scp, rsync, git).

--
Regards,
Paweďż˝

G Drukier

unread,
Nov 10, 2010, 11:27:33 AM11/10/10
to Paweł Zuzelski, gito...@googlegroups.com

> Paweł

Thanks to everyone for the solutions. I can get at my repositories now.

Reply all
Reply to author
Forward
0 new messages