<div dir="ltr">Hi Thomas,<div><br></div><div>Hmm, let me try to see if I can say it better. For an outgoing UDP datagram (from a containerized mosh-server to a mosh-client), the mosh-server will be sending the datagram from some private IP address (the container&#39;s IP address, e.g. 10.0.0.5) and a source port that is probably going to be the same across all containers (like 60001), since each container will probably only be running one mosh-server.</div><div><br></div><div>The proxy will want to rewrite the source IP:port so that the source IP address is the proxy&#39;s routable Internet address and the port number is whatever unique port it assigned and sent to the client in the original MOSH CONNECT message that the client saw.</div><div><br></div><div>-Keith</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jul 7, 2018 at 8:32 PM, Thomas Buckley-Houston <span dir="ltr">&lt;<a href="mailto:tom@tombh.co.uk" target="_blank">tom@tombh.co.uk</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks so much for this idea, I really think it&#39;s the one, simple and scalable.<br>
<br>
I haven&#39;t tried but I&#39;m pretty sure the mosh-server&#39;s &quot;MOSH CONNECT&quot;<br>
can be wrapped in plain BASH. I&#39;m already in control of the SSH<br>
connection as I&#39;m using my own `ForceCommand` script.<br>
<br>
Also I can still use this method with extra Round-Robin balanced IP<br>
addresses giving me multiple sets of 65,000 ports.<br>
<br>
The only thing I don&#39;t understand is why the outgoing UDP datagram has<br>
to rewrite the container&#39;s source IP. Isn&#39;t the original MOSH CONNECT<br>
IP:port the canonical reference?<br>
<div class="HOEnZb"><div class="h5"><br>
On 1 July 2018 at 12:54, Keith Winstein &lt;<a href="mailto:keithw@cs.stanford.edu">keithw@cs.stanford.edu</a>&gt; wrote:<br>
&gt; How about a semi-smart (but mostly Mosh-oblivious) server-side proxy/NAT<br>
&gt; that works like this:<br>
&gt;<br>
&gt; - The proxy service has one public IP address and like 65,000 available UDP<br>
&gt; ports.<br>
&gt; - The proxy service can itself be redundant with failover...<br>
&gt; - When a user wants to open a new Mosh connection, they Mosh to a single<br>
&gt; hostname (which resolves to the IP address of the proxy service).<br>
&gt; - Your code allocates the necessary container, etc., and also allocates a<br>
&gt; unique UDP port on the proxy.<br>
&gt; - Your code runs the new mosh-server process in the target container.<br>
&gt; - The proxy intercepts the mosh-server&#39;s &quot;MOSH CONNECT &lt;port&gt; &lt;key&gt;&quot;<br>
&gt; message, replacing the port number with the unique public-facing UDP port<br>
&gt; (and remembering the container&#39;s IP address and the original port number).<br>
&gt; - When the proxy receives an incoming UDP datagram destined to a particular<br>
&gt; UDP port, it forwards it to the appropriate container at its IP address and<br>
&gt; at the original port number. It *preserves* the source IP and port of the<br>
&gt; datagram when forwarding.<br>
&gt; - When the container wants to send an outgoing UDP datagram, it sends it<br>
&gt; normally (to whatever IP:port is associated with the client), except the<br>
&gt; containers are not directly connected to the Internet; they use the<br>
&gt; proxy/NAT as their next-hop router.<br>
&gt; - For the outgoing UDP datagram, the proxy/NAT rewrites the container&#39;s<br>
&gt; source IP:port to its own IP and the public port number.<br>
&gt;<br>
&gt; I think this will allow you to serve like 65,000 separate mosh connections<br>
&gt; from a single public IP address...<br>
&gt;<br>
&gt; The added latency in forwarding a datagram is probably &lt;1 ms, and you don&#39;t<br>
&gt; really have to change anything about Mosh itself or its internals.<br>
&gt;<br>
&gt; Unfortunately there are no unencrypted identifying marks to a Mosh<br>
&gt; connection, except the incrementing sequence numbers (which start at 0 for<br>
&gt; every connection).<br>
&gt;<br>
&gt; -Keith<br>
&gt;<br>
&gt; On Fri, Jun 29, 2018 at 12:17 AM, Thomas Buckley-Houston &lt;<a href="mailto:tom@tombh.co.uk">tom@tombh.co.uk</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hey Keith, John, everyone,<br>
&gt;&gt;<br>
&gt;&gt; Yeah the more this is looking like a quite a big hurdle. Especially<br>
&gt;&gt; your point Keith about roaming IPs (which I&#39;d forgotten), it&#39;s a<br>
&gt;&gt; central feature of Mosh I don&#39;t want to lose.<br>
&gt;&gt;<br>
&gt;&gt; So the only 2 options seems to be exposing multiple IPs for Round<br>
&gt;&gt; Robin (or other smart DNS routing) or writing a new Mosh proxy that<br>
&gt;&gt; already has knowledge of the existing keys. Both seem like quite a<br>
&gt;&gt; challenge. Round Robin DNS seems more approachable and I can imagine<br>
&gt;&gt; integrating it with the Google Cloud DNS API I&#39;m already using, but I<br>
&gt;&gt; just wonder how expensive Google (or anyone for that matter) will make<br>
&gt;&gt; thousands of static IP addresses? Apart from me having to learn Mosh<br>
&gt;&gt; internals, one difficulty that strikes me about a Mosh proxy is that<br>
&gt;&gt; it might introduce a non-trivial delay to each datagram arriving?<br>
&gt;&gt; Though surely only ever in the order of a handful of milliseconds I<br>
&gt;&gt; suppose.<br>
&gt;&gt;<br>
&gt;&gt; Are there not any other identifying marks to a datagram, I don&#39;t know<br>
&gt;&gt; much about low level networking, but maybe something like a MAC<br>
&gt;&gt; address for example?<br>
&gt;&gt;<br>
&gt;&gt; Thanks,<br>
&gt;&gt; Tom<br>
&gt;&gt;<br>
&gt;&gt; On 27 June 2018 at 04:50, Keith Winstein &lt;<a href="mailto:keithw@cs.stanford.edu">keithw@cs.stanford.edu</a>&gt; wrote:<br>
&gt;&gt; &gt; Hi Thomas,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Glad you could provoke a very interesting discussion! But I&#39;m still<br>
&gt;&gt; &gt; confused<br>
&gt;&gt; &gt; -- how is &quot;sticky IP-based routing&quot; going to work after the client roams<br>
&gt;&gt; &gt; to<br>
&gt;&gt; &gt; a new IP address (or to a new UDP source port)? When your system seems<br>
&gt;&gt; &gt; an<br>
&gt;&gt; &gt; incoming UDP datagram from a previously unseen source IP:port, how does<br>
&gt;&gt; &gt; it<br>
&gt;&gt; &gt; know which mosh-server (on which server machine) to send it to?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; With off-the-shelf Mosh, you basically need a load-balancing strategy<br>
&gt;&gt; &gt; that<br>
&gt;&gt; &gt; allows a destination IP:port to uniquely identify a particular<br>
&gt;&gt; &gt; mosh-server.<br>
&gt;&gt; &gt; You can do this with multiple DNS A/AAAA records (where the client picks<br>
&gt;&gt; &gt; the<br>
&gt;&gt; &gt; winning one -- maybe you permute the list), or with a smart DNS server<br>
&gt;&gt; &gt; that<br>
&gt;&gt; &gt; serves *one* A or AAAA record to the client at the time of resolution<br>
&gt;&gt; &gt; (like<br>
&gt;&gt; &gt; a CDN would use).<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Instead of using the mosh wrapper script, you could have your users use<br>
&gt;&gt; &gt; some<br>
&gt;&gt; &gt; other scheme to figure out the IP:port of the server, but the point is<br>
&gt;&gt; &gt; that<br>
&gt;&gt; &gt; once you launch the mosh-client, it&#39;s going to keep sending datagrams to<br>
&gt;&gt; &gt; the<br>
&gt;&gt; &gt; IP:port of the mosh-server, and those datagrams need to get to the same<br>
&gt;&gt; &gt; mosh-server process even if the client roams to a different<br>
&gt;&gt; &gt; publicly-visible<br>
&gt;&gt; &gt; IP address or port.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; You could imagine writing a very smart mosh proxy that has the keys to<br>
&gt;&gt; &gt; all<br>
&gt;&gt; &gt; the sessions and can figure out (for an incoming datagram coming from an<br>
&gt;&gt; &gt; unknown source IP:port) which session it actually belongs to, and then<br>
&gt;&gt; &gt; makes<br>
&gt;&gt; &gt; a sticky mapping and routes it to the proper mosh-server. But I don&#39;t<br>
&gt;&gt; &gt; think<br>
&gt;&gt; &gt; anybody has actually done this yet and of course there&#39;s a challenge in<br>
&gt;&gt; &gt; making this reliable/replicated.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; -Keith<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Mon, Jun 25, 2018 at 3:10 AM, Thomas Buckley-Houston<br>
&gt;&gt; &gt; &lt;<a href="mailto:tom@tombh.co.uk">tom@tombh.co.uk</a>&gt;<br>
&gt;&gt; &gt; wrote:<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Thanks so much for the clarification.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt; UDP is connectionless<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; That&#39;s the key here. So I have no choice but to use sticky IP-based<br>
&gt;&gt; &gt;&gt; routing. Round-robin DNS isn&#39;t an option I don&#39;t think, because I hope<br>
&gt;&gt; &gt;&gt; one day to be able to scale to thousands of servers.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; And thanks so much for the heads up about my DNSSEC records. I&#39;ve sent<br>
&gt;&gt; &gt;&gt; a request for them to be deleted. I&#39;d added them and some SSHFP<br>
&gt;&gt; &gt;&gt; records to explore automatically passing the StrictHostKey warning.<br>
&gt;&gt; &gt;&gt; But it&#39;s not entirely straight forward. Even with correct DNS records<br>
&gt;&gt; &gt;&gt; the SSH user still has to have VerifyHostKeyDNS enabled, which as I<br>
&gt;&gt; &gt;&gt; understand most people don&#39;t. And then on top of that my DNS provider<br>
&gt;&gt; &gt;&gt; (DNSSimple) automatically rotate the keys every 3 months, which means<br>
&gt;&gt; &gt;&gt; I have to manually send a request to my registrars by email to update<br>
&gt;&gt; &gt;&gt; the DNSSEC records. Is it all worth it do you think?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; On 24 June 2018 at 13:36, Anders Kaseorg &lt;<a href="mailto:andersk@mit.edu">andersk@mit.edu</a>&gt; wrote:<br>
&gt;&gt; &gt;&gt; &gt; You may have a misunderstanding about how a Mosh session is set up.<br>
&gt;&gt; &gt;&gt; &gt; The<br>
&gt;&gt; &gt;&gt; &gt; mosh script launches a mosh-server on the remote system via SSH;<br>
&gt;&gt; &gt;&gt; &gt; mosh-server picks a port number and a random encryption key, and<br>
&gt;&gt; &gt;&gt; &gt; writes<br>
&gt;&gt; &gt;&gt; &gt; them to stdout, where they go back over SSH to the mosh script; then<br>
&gt;&gt; &gt;&gt; &gt; the<br>
&gt;&gt; &gt;&gt; &gt; mosh script launches mosh-client passing the IP address, port number,<br>
&gt;&gt; &gt;&gt; &gt; and<br>
&gt;&gt; &gt;&gt; &gt; encryption key.  The newly launched mosh-client and mosh-server<br>
&gt;&gt; &gt;&gt; &gt; processes<br>
&gt;&gt; &gt;&gt; &gt; exchange UDP packets encrypted with the shared key; communication is<br>
&gt;&gt; &gt;&gt; &gt; successful if the packets can be decrypted.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; There’s no separate “key checking” step to be disabled.  And it<br>
&gt;&gt; &gt;&gt; &gt; doesn’t<br>
&gt;&gt; &gt;&gt; &gt; make sense to “refuse more than 1 connection on the same port”, both<br>
&gt;&gt; &gt;&gt; &gt; because UDP is connectionless, and because a new mosh-server is<br>
&gt;&gt; &gt;&gt; &gt; launched<br>
&gt;&gt; &gt;&gt; &gt; on a new port for each Mosh session (it is not a daemon like sshd).<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; The easiest way to put Mosh servers behind a load balancer is with<br>
&gt;&gt; &gt;&gt; &gt; round-robin DNS where a single hostname resolves to many addresses,<br>
&gt;&gt; &gt;&gt; &gt; or<br>
&gt;&gt; &gt;&gt; &gt; to<br>
&gt;&gt; &gt;&gt; &gt; different addresses for different clients and/or at different times.<br>
&gt;&gt; &gt;&gt; &gt; We’ve already gone out of our way to make the mosh script resolve the<br>
&gt;&gt; &gt;&gt; &gt; hostname only once and use the same address for the SSH connection<br>
&gt;&gt; &gt;&gt; &gt; and<br>
&gt;&gt; &gt;&gt; &gt; the<br>
&gt;&gt; &gt;&gt; &gt; UDP packets, because that’s needed for MIT’s <a href="http://athena.dialup.mit.edu" rel="noreferrer" target="_blank">athena.dialup.mit.edu</a><br>
&gt;&gt; &gt;&gt; &gt; pool.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; If that’s not an option and you really need all connections to go<br>
&gt;&gt; &gt;&gt; &gt; through<br>
&gt;&gt; &gt;&gt; &gt; a single load balancer address, you could try wrapping mosh-server in<br>
&gt;&gt; &gt;&gt; &gt; a<br>
&gt;&gt; &gt;&gt; &gt; script that passes different disjoint port ranges (-p) on different<br>
&gt;&gt; &gt;&gt; &gt; backends, and forwarding those ranges to the corresponding backends<br>
&gt;&gt; &gt;&gt; &gt; from<br>
&gt;&gt; &gt;&gt; &gt; the load balancer.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; Unrelatedly, brow.sh doesn’t resolve with DNSSEC-enabled resolvers<br>
&gt;&gt; &gt;&gt; &gt; like<br>
&gt;&gt; &gt;&gt; &gt; 1.1.1.1 or 8.8.8.8, seemingly due to some problem with the DS records<br>
&gt;&gt; &gt;&gt; &gt; set<br>
&gt;&gt; &gt;&gt; &gt; with the registrar: <a href="https://dnssec-debugger.verisignlabs.com/brow.sh" rel="noreferrer" target="_blank">https://dnssec-debugger.<wbr>verisignlabs.com/brow.sh</a>.<br>
&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; Anders<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; &gt;&gt; mosh-devel mailing list<br>
&gt;&gt; &gt;&gt; <a href="mailto:mosh-devel@mit.edu">mosh-devel@mit.edu</a><br>
&gt;&gt; &gt;&gt; <a href="http://mailman.mit.edu/mailman/listinfo/mosh-devel" rel="noreferrer" target="_blank">http://mailman.mit.edu/<wbr>mailman/listinfo/mosh-devel</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; mosh-devel mailing list<br>
&gt;&gt; <a href="mailto:mosh-devel@mit.edu">mosh-devel@mit.edu</a><br>
&gt;&gt; <a href="http://mailman.mit.edu/mailman/listinfo/mosh-devel" rel="noreferrer" target="_blank">http://mailman.mit.edu/<wbr>mailman/listinfo/mosh-devel</a><br>
&gt;<br>
&gt;<br>
<br>
______________________________<wbr>_________________<br>
mosh-devel mailing list<br>
<a href="mailto:mosh-devel@mit.edu">mosh-devel@mit.edu</a><br>
<a href="http://mailman.mit.edu/mailman/listinfo/mosh-devel" rel="noreferrer" target="_blank">http://mailman.mit.edu/<wbr>mailman/listinfo/mosh-devel</a><br>
</div></div></blockquote></div><br></div>