News for hackers. Stuff that matters.
Re:Show HN: Run SSH and HTTP(S) on the same port by antoaravinth on Wednesday January 21, 2015 @09:05PM (#8927101)
A simple question. How come two programs can run on the same port? How does this being implemented?
Re:Show HN: Run SSH and HTTP(S) on the same port by thedufer on Wednesday January 21, 2015 @09:54PM (#8927282)
I haven't read it too carefully but typically something like this would be done by having one program run on the port in question and then it would determine which protocol a given connection is speaking and hand it off to a different port based on config. So your https and ssh servers run on, say, 2000 and 3000 and the protocol recognizer runs on 443 and hands off connections to either 2000 or 3000. See, for example, reverse-proxying with nginx or haproxy.
Re:Show HN: Run SSH and HTTP(S) on the same port by antoaravinth on Thursday January 22, 2015 @04:21AM (#8928275)
Ya I guess this is the way that they would have implemented.
Re:Show HN: Run SSH and HTTP(S) on the same port by dfox on Wednesday January 21, 2015 @10:20PM (#8927363)
For the case of ssh versus ssl the detection is trivial: first message for ssl comes from client but for ssh first message comes from server. So server simply waits for a while and assumes that client speaks ssh when it does not receive anything.

One can also match whatever is received in first message from client against known protocols (this approach makes it possible to for example run HTTP and HTTPS on same port as is done by IPP servers, particularly CUPS).

Re:Show HN: Run SSH and HTTP(S) on the same port by antoaravinth on Thursday January 22, 2015 @04:22AM (#8928279)
What do you mean by:

       first message for ssl comes from client but for ssh first message comes from server
Re:Show HN: Run SSH and HTTP(S) on the same port by userbinator on Thursday January 22, 2015 @09:04AM (#8929149)
With SSL/TLS, the client connects and sends a ClientHello message first, and then the server responds; with SSH, the server will send a version string upon connection (and expects the client to do the same). With plain HTTP, the client sends the request first. The server can detect which one of these cases it is.
Re:Show HN: Run SSH and HTTP(S) on the same port by antoaravinth on Thursday January 22, 2015 @11:07AM (#8929849)
I'm still being not clear of what you mean by:

>with SSH, the server will send a version string upon connection (and expects the client to do the same).

Say for example if I do:

   ssh some.machine.com
I'm (being the client ) call the ssh port ( server ) running on the some.machine.com, right? If thats the case, client is who starting the conversation right?

Correct me if I'm wrong.

Re:Show HN: Run SSH and HTTP(S) on the same port by nickcano on Thursday January 22, 2015 @06:54PM (#8932578)
Establishing a connection isn't considered 'sending a message'.
Re:Show HN: Run SSH and HTTP(S) on the same port by antoaravinth on Friday January 23, 2015 @12:14AM (#8933508)
Oh ok. Now I understood, thanks.