Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change port separator to semicolon : since it's more standard #222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

david-alvarez-rosa
Copy link

Kindly suggesting to switch to semicolon character : as port separator as [user@]hostname[:port]. Current port separator is ^ which is less standard -- semicolon is used both in ssh and scp programs.

For maintaining backward compatibility, similar to the support of legacy /, the character ^ can still be supported.

Appendix

A bit of history:

  • From what I've been able to understand from Git history, everything started in 2008 with the usage of / as port separator, implemented in 1.

  • Five years later, in 2013, This was changed 2 to # to fix a problem related to scp. Not sure, but a plausible reason for this could be a clash with the usage of / for directories. Note that the usage of / was still allowed as legacy.

  • That same year it was changed again 3 to % for some reason I have not been able to understand.

  • Then, in 2014, since % is used by IPv6 addresses, this was changed 4 to use ^ as port separator -- and this is the current state.

As a comment, / is still supported as legacy.

Kindly suggesting to switch to semicolon character `:` as port separator
as `[user@]hostname[:port]`.  Current port separator is `^` which is
less standard -- semicolon is used both in `ssh` and `scp` programs.

For maintaining backward compatibility, similar to the support of legacy
`/`, the character `^` can still be supported.

Appendix
--------

A bit of history:

 - From what I've been able to understand from Git history, everything
   started in 2008 with the usage of `/` as port separator, implemented
   in [1].

 - Five years later, in 2013, This was changed [2] to `#` to fix a
   problem related to `scp`.  Not sure, but a plausible reason for this
   could be a clash with the usage of `/` for directories.  Note that
   the usage of `/` was still allowed as legacy.

 - That same year it was changed again [3] to `%` for some reason I have
   not been able to understand.

 - Then, in 2014, since `%` is used by IPv6 addresses, this was changed
   [4] to use `^` as port separator -- and this is the current state.

As a comment, `/` is still supported as legacy.

[1]: mkj@d981ff2
[2]: mkj@3525cab
[3]: mkj@f98eb58
[4]: mkj@0c9a643
@@ -205,7 +205,7 @@ in the example above, the same way as other -L TCP forwarded hosts are. Host key
checked locally based on the given hostname.

.SH ESCAPE CHARACTERS
Typing a newline followed by the key sequence \fI~.\fR (tilde, dot) will terminate a connection.
Typing a newline followed by the key sequence \fI~.\fR (tilde, dot) will terminate a connection.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an not related typo.

@@ -194,7 +194,7 @@ Dropbear will also allow multiple "hops" to be specified, separated by commas. I
this case a connection will be made to the first host, then a TCP forwarded
connection will be made through that to the second host, and so on. Hosts other than
the final destination will not see anything other than the encrypted SSH stream.
A port for a host can be specified with a caret (eg matt@martello^44 ).
A port for a host can be specified with a caret (eg matt@martello:44 ).
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed this.

Suggested change
A port for a host can be specified with a caret (eg matt@martello:44 ).
A port for a host can be specified with a colon (eg matt@martello:44 ).

@david-alvarez-rosa
Copy link
Author

david-alvarez-rosa commented Mar 24, 2023

My bad, just noticed that : is called colon (not semicolon). Will fix in rev. 2 if approach is validated :)

@mkj
Copy link
Owner

mkj commented Apr 26, 2023

The syntax here is only for multihop, which OpenSSH added later with their -J option, the syntax being a little bit different.

I think the reason I avoided : was because it is used for ipv6 separators. I guess that should be OK if it can handle the standard [] quoting, maybe by using split_address_port()

int split_address_port(const char* spec, char **first, char ** second) {

I can't remember exactly but assume the reason # was removed was because it was hard to type without it being treated as a shell comment. / being treated as a directory separator sounds likely.

@HansH111
Copy link
Contributor

I believe the : was avoided because of the scp use for specifying the destination filename/path like scp -P port user@host:filename
if you do multihops with different ports you will get : scp user@host1:2022,user@host2:3022:filename
instead of scp user@host1^2022,user@host2^3022:filename
But I might be wrong

@mkj
Copy link
Owner

mkj commented Mar 31, 2024

I believe the : was avoided because of the scp use for specifying the destination filename/path like scp -P port user@host:filename

Ah yes, I think that's right. So even with [] for ipv6, a colon might be problematic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants