# SSH port ignored when ssh:// prefix isn't specified

3 messages from 2017-12-10 to 2017-12-10. Participants: mqudsi@neosmart.net, Matthieu Moy, Randall S. Becker.
Thread: https://gitlist.dev/t/47420

## mqudsi@neosmart.net, 2017-12-10 20:23

Subject: SSH port ignored when ssh:// prefix isn't specified
Message-ID: <0101016042190a3b-091dfab3-e010-4fbe-94e7-739ae3090883-000000@us-west-2.amazonses.com>
URL: https://gitlist.dev/e/0101016042190a3b-091dfab3-e010-4fbe-94e7-739ae3090883-000000%40us-west-2.amazonses.com

```
Greetings,

It appears that for non-standard ports to be specified for ssh-based
clones/checkouts, the leading "ssh://" prefix must be applied. I am unsure if
there's a reason for this or if it is simply an overlooked idiosyncrasy in the
parser.

Basically, while `git clone ssh://git@example.com:2222/path` works, the same
with the `ssh://` prefix doesn't, and attempts to establish a connection to
port 22 instead: `git clone git@example.com:2222/path` (I'm not sure what it
will do with the `:2222` should the connection actually succeed).

Mahmoud Al-Qudsi
NeoSmart Technologies


```

## Matthieu Moy, 2017-12-10 20:31

Subject: Re: SSH port ignored when ssh:// prefix isn't specified
Message-ID: <q7h9y3mamik4.fsf@orange.lip.ens-lyon.fr>
URL: https://gitlist.dev/e/q7h9y3mamik4.fsf%40orange.lip.ens-lyon.fr
In-Reply-To: <0101016042190a3b-091dfab3-e010-4fbe-94e7-739ae3090883-000000@us-west-2.amazonses.com>

```
"mqudsi@neosmart.net" <mqudsi@neosmart.net> writes:

> Basically, while `git clone ssh://git@example.com:2222/path` works, the same
> with the `ssh://` prefix doesn't, and attempts to establish a connection to
> port 22 instead: `git clone git@example.com:2222/path` (I'm not sure what it
> will do with the `:2222` should the connection actually succeed).


I don't see a simple way to distinguish between "I want to connect to
port 22 and access directory 2222/path" and "I want to connect to port
2222 and access directory path". So Git chose for you the first option
(if you replace 2222 with abcd, it clearly makes sense).

-- 
Matthieu Moy
https://matthieu-moy.fr/

```

## Randall S. Becker, 2017-12-10 21:42

Subject: RE: SSH port ignored when ssh:// prefix isn't specified
Message-ID: <000a01d371ff$c2aca590$4805f0b0$@nexbridge.com>
URL: https://gitlist.dev/e/000a01d371ff%24c2aca590%244805f0b0%24%40nexbridge.com
In-Reply-To: <0101016042190a3b-091dfab3-e010-4fbe-94e7-739ae3090883-000000@us-west-2.amazonses.com>

```
On December 10, 2017 3:24 PM Mahmoud wrote:

>It appears that for non-standard ports to be specified for ssh-based
clones/checkouts, the leading "ssh://" prefix must
>be applied. I am unsure if there's a reason for this or if it is simply an
overlooked idiosyncrasy in the parser.

>Basically, while `git clone ssh://git@example.com:2222/path` works, the
same with the `ssh://` prefix doesn't,
>and attempts to establish a connection to port 22 instead: `git clone
git@example.com:2222/path` (I'm not
>sure what it will do with the `:2222` should the connection actually
succeed).

Git is attempting to resolve the repository "2222/path" as it's default
behaviour since the ssh method is not specified. This is a situation where
the default is ambiguous so while git is choosing the ssh method, it is also
choosing repository resolution after the ':' which is also default
behaviour.

Cheers,
Randall

-- Brief whoami: NonStop&UNIX developer since approximately
UNIX(421664400)/NonStop(211288444200000000) 
-- In my real life, I talk too much.




```
