Slashdot Mirror


Mosh: Modernizing SSH With IP Roaming, Instant Local Echo

An anonymous reader writes "Launched in 1995, SSH quickly became the king of network login tools, supplanting the old insecure mainstays TELNET and RLOGIN. But 17 years later, a group of MIT hackers have come out with "mosh", which claims to modernize the most annoying parts of SSH. Mosh keeps its connection alive when clients roam among WiFi networks or switch to 3G, and gives instant feedback on typing (and deleting). No more annoying network lag on typing, the MIT boffins say, citing Bufferbloat, which has been increasing latencies." The folks involved have a pre-press research paper with the gritty details (to be presented at USENIX later this year). Mosh itself is not particularly exciting; the new State Synchronization Protocol it is based upon might be: "This is accomplished using a new protocol called the State Synchronization Protocol, for which Mosh is the first application. SSP runs over UDP, synchronizing the state of any object from one host to another. Datagrams are encrypted and authenticated using AES-128 in OCB mode. While SSP takes care of the networking protocol, it is the implementation of the object being synchronized that defines the ultimate semantics of the protocol."

41 of 158 comments (clear)

  1. First they invented telnet, which had... by ArsenneLupin · · Score: 4, Insightful
    ... a negotiable LOCAL_ECHO mode. Then they invented ssh, and left away that LOCAL_ECHO and linebuffered flags, considered to be archaic.

    And 15 years later, LOCAL_ECHO is back in mosh!

    1. Re:First they invented telnet, which had... by Animats · · Score: 4, Interesting

      .. a negotiable LOCAL_ECHO mode. Then they invented ssh, and left away that LOCAL_ECHO and linebuffered flags, considered to be archaic. And 15 years later, LOCAL_ECHO is back in mosh!

      Right. Breaking local echo in Telnet was a Berkeley misfeature. It was in 3COM's UNET, which predated Berkley networking in UNIX. (Berkeley did not introduce networking in UNIX. Theirs was the third or fourth implementation, after ones from BBN, 3COM, and Phil Karn.) With UNET, circa 1983, Telnet had local echo until you used something like VI or the RAND full screen editor, at which point the server noticed the stty call which switched to "raw mode" and switched to remote echo.

      Seamless transition from local echo to remote echo is even older. It was in Tymnet, which used markers called a "red ball" and a "green ball" to do the switch seamlessly.

  2. Pass on the local echo please! by Anrego · · Score: 5, Insightful

    and gives instant feedback on typing (and deleting).

    That sounds like a step backwards to me. Any utility in that is lost when something doesn’t sync up properly. When I hit a key, I want to know it has been sent and received and see the result.. not see the result as my shell predicts it. Maybe I’m just having local echo flashbacks from past telnet experiences.

    Everything else sounds really neat though. I don’t jump wifi often enough for re-connecting and re-attaching to screen to be a big deal.. but I can see the utility for those who do.

    1. Re:Pass on the local echo please! by Anonymous Coward · · Score: 5, Informative

      From their website:

      Disable instant echo

      $ mosh --predict=never niennunb

      The -n switch is a synonym. By contrast, passing --predict=always or -a will enable instant local echo even on low-delay links.

      Sounds like it tries to be smart about this, but not so smart as to not allow a human to force things the way he wants them.

    2. Re:Pass on the local echo please! by Anonymous Coward · · Score: 5, Informative

      According to their website, locally echoed but not yet synced input is visually distinct from synced content, so you'll always know what has been sent and what hasn't.

    3. Re:Pass on the local echo please! by Anonymous Coward · · Score: 5, Informative

      I've been using it for a few days now, and I find the local echo to be quite a useful feature. Many of the machines I remotely use are on different continents, and waiting for my keypress to make a round trip can be frustrating at times.

      Mosh also makes it clear which characters have been successfully transmitted by underlining those that are still finding their way through the tubes... i've never been unsure what has or has not been received.

      After a few days of using mosh, I don't see myself going back to plain old ssh anytime soon.

    4. Re:Pass on the local echo please! by Jeremi · · Score: 2

      That sounds like a step backwards to me. Any utility in that is lost when something doesnâ(TM)t sync up properly. When I hit a key, I want to know it has been sent and received and see the result.. not see the result as my shell predicts it.

      Easy to say until you are (attempting to) type in a longish shell command into a server across an overloaded Internet connection. In that situation, you have two choices: either wait 1 second after each character, to make sure you typed it correctly, or blindly type a bunch of characters at once and hope you didn't make any typos. And if you did make a typo, then you're really in the sh*t, because now you have to figure out how many characters you actually since then, and press backspace EXACTLY that number of times, plus one, and then retype the mistyped character and the newer ones. And if you get THAT wrong, then you're completely hosed, and all you can do is wait the necessary 15-30 seconds for everything to (presumably) sync up, and then figure out what you need to do next.

      Either method is infuriating, and unnecessary. Since your shell command is only valid as a whole, and will only be executed after you press return, there is no point in sync'ing with the server except at the point where you press return.

      --


      I don't care if it's 90,000 hectares. That lake was not my doing.
  3. Obsolete within five years by mikael_j · · Score: 2, Interesting

    While neat for those who are currently in areas with spotty wireless coverage it is a neat idea but for most users I don't think it's that much of an issue, even at the moment.

    Fast forward five years and I just don't see this software being all that useful. Sure, there's always gonna be that handful of people who will scream that this is extremely useful because they're always hopping between wifi hotspots but most users are using 3G/4G when they're on the move and coverage for those is already "good enough" in most civilized places and steadily improving. I've taken 5+ hour train trips several times and only had ssh connections drop once or twice on those trips (due to spotty coverage in what would quality as the middle of nowhere in northern Sweden).

    This is like "solving" the IPv4 address exhaustion problem with NAT, it's a neat workaround but doesn't actually solve the problem.

    --
    Greylisting is to SMTP as NAT is to IPv4
    1. Re:Obsolete within five years by TeknoHog · · Score: 2

      Fast forward five years and I just don't see this software being all that useful. Sure, there's always gonna be that handful of people who will scream that this is extremely useful because they're always hopping between wifi hotspots but most users are using 3G/4G when they're on the move

      Dunno about 4G, but 3G has enough latency to make ssh annoying, so Mosh would definitely be an improvement.

      --
      Escher was the first MC and Giger invented the HR department.
    2. Re:Obsolete within five years by Kidbro · · Score: 2

      I just started using it (after seeing this article) to connect from my laptop which I suspend and carry in my backpack from work to home. Opened the lid, and the session is still seemingly intact after the few seconds it takes to find my home wifi.
      No 4G connection in the world is gonna help a device that's effectively turned off.

      I don't think this is a very unusual use case.

    3. Re:Obsolete within five years by silanea · · Score: 3, Insightful

      If we only ever built technology that appeared immediately useful for at least 95% of the population we would still be trying to figure out how to transport messages across long distances without using a horse.

      --
      Rudolf Hess edited Mein Kampf. He was the very first grammar nazi.
    4. Re:Obsolete within five years by thegarbz · · Score: 2

      This is like "solving" the IPv4 address exhaustion problem with NAT, it's a neat workaround but doesn't actually solve the problem.

      I think you're not focusing on what the actual "problem" is. NAT really is a bandaid solution for a lack of IP addresses. NAT does solve the issue of multiple devices sharing an common WAN address.

      Mosh addresses the issues of connections essentially being treated as static routes no more no less. The problem is the proliferation of different protocols and networks and devices which attempt to seemlessly hop between them to remain in a coverage area. While the hopping bit works quite well (as soon as I am near my house my device switches to WiFi) any persistent connections would be lost. This was not a problem with for instance 3G / 4G coverage as the underlying network protocols will seemlessly transition from one tower to the next, however it fails where you start bouncing from one technology to another.

      This is only going to get worse as more WiFi hotspots appear, cities run their own WiFi networks, different mobile phone technologies emerge, and we become more and more mobile. Unlike using NAT for lack of IPv4 as a bandaid which essentially breaks some services, the idea of creating a protocol that can pick up from where it left off is really a well thought out solution to a specific problem.

  4. Re:UDP for a connection which has to -reliably- se by ZorinLynx · · Score: 4, Insightful

    If they implement their own TCP-like layer over UDP, there's no reason it can't be just as reliable.

    It's kind of hard to do things like roaming using TCP because endpoint IPs can change.

  5. OCB Mode is Toxic. by TechyImmigrant · · Score: 4, Interesting

    We tried to put OCB mode in 802.11i. So IBM sent a guy to explain the 'licensing terms' for their patents on OCB mode. The next vote in 802.11i after that presentation was to replace OCB mode with CCM.

    Until the patents expire or are freely licensed, OCB mode should be considered off limits for free and open projects.

    --
    I should use this sig to advertise my book ISBN-13 : 978-1501515132.
    1. Re:OCB Mode is Toxic. by Anonymous Coward · · Score: 2, Informative

      according to Wikipedia:

      Two U.S. patents have been issued for OCB mode. [1] However, a special exemption has been granted so that OCB mode can be used in software licensed under the GNU General Public License without cost, as well as for any non-commercial, non-governmental application. Since the authors have only applied for patent protection in the U.S., the algorithm is free to use in software not developed and not sold inside the U.S. [2].

    2. Re:OCB Mode is Toxic. by mikechant · · Score: 5, Informative

      The patents are freely licensed for any GPL software; see link for details.
      http://www.cs.ucdavis.edu/~rogaway/ocb/offer.htm

      Mosh appears to be GPL:
      https://github.com/keithw/mosh/blob/master/COPYING

    3. Re:OCB Mode is Toxic. by vlm · · Score: 2

      It would be an interesting battle. I read the Rogaway original paper years ago and he was granting free use to anything GPL licensed. For a more modern view you can also see"

      http://www.cs.ucdavis.edu/~rogaway/ocb/license.htm

      I've looked into MOSH recently, and it is GPL. The battle would be, does mosh live under Rogaway's OCB patents which makes it free, or IBMs patents, which makes it unclear... From a "money is justice" perspective, I donno if ucdavis would win against IBM, but they'd have better odds than "just a bunch of random hackers" vs IBM.

      To burn an informative couple hours on the topic, simply google for "rogaway OCB" and start reading.

      --
      "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
  6. Re:I stopped reading after this by isama · · Score: 2

    So that means it's just like GNU Screen? ctrl+a d on one connection, hop wifi, ssh and screen -x. wow. Really?

  7. Other improvements ? by redelm · · Score: 5, Interesting

    IP roaming looks nice & ought to be secure with the right steps (no reply from old IP:port, correct cryto negotiation with new IP:port).

    But LOCAL ECHO is a big problem -- applications have to be aware of it. On CLI, many keystrokes are commands, not text to be entered. On vi in command-mode, G goes to the last line.

    Personally, a bigger thing is traffic reduction, particularly keystoke combining. Nagel's algorithm is a start, but I've modded ssh to delay and buffer likely-text keystrokes for a short time (400ms) while letting likely commands through immediately to retain responsiveness. The delays aren't irksome, and I reduce outbound traffic by ~80%.

  8. Younger coders usually think they know best.. by Viol8 · · Score: 2

    Then they discover there was usually a good reason for something being done the way it was in the past. Eg local echo was very useful for line buffered programs such as MUDs and chat servers or even talking to SENDMAIL or an FTP server directly. It was easier to write the server to cope with just line by line rather than character by character and it used up less network resources in the process.

    1. Re:Younger coders usually think they know best.. by Malties · · Score: 2

      These younger coders don't know what network lag is. In my day I had a connection that was so slow I could type faster than my 150 baud modem could send the keystrokes.

    2. Re:Younger coders usually think they know best.. by gregben · · Score: 2

      My first computer experience (1972) was at 110 baud, banging away
      on an ASR-33 Teletype connected via leased line to a DEC PDP-8 running Dartmouth Basic.

      I'd get up and run a lap around the building for fresh air while printing
      a program listing. Data rate in/out was 10 CPS (Characters Per Second).

      I recall proudly showing my dad the program listing at home, unrolled on the living room floor at about 10 or 12 feet long...

    3. Re:Younger coders usually think they know best.. by Drishmung · · Score: 2
      150bps backchannel on a 1200bps modem. I.e. 1200/150 so typing (uplink) would certainly be 150bps.

      Here is a data sheet for such a modem

      --
      Protoplasm. Quiet Protoplasm. I like quiet protoplasm.
  9. Re:I stopped reading after this by Imagix · · Score: 2

    I think the point this has is that it will automatically do the reconnect for you. What I'm not sold on is that this now requires an arbitrary port to be open on the server side in order to connect to the mosh server, and how irritated are the security guys who control the edge firewalls on your corporate network going to get?

  10. Re:Why would I want this compatibility break? by Hes+Nikke · · Score: 4, Insightful

    You, now:

    so I can ssh into every server, but only mosh into a few.

    You, 1995:

    so I can telnet into every server, but only ssh into a few.

    --
    Don't call me back. Give me a call back. Bye. So yeah. But bye our, well, but alright we are on a shirt this chill.
  11. Firewalls by Alarash · · Score: 5, Insightful
    Reading the linked research paper a bit, and something strikes me.

    We use the existing infrastructure for authenticating hosts and users. To bootstrap an SSP connection, the user ïrst logs in to the remote host using conventional means, such as SSH or Kerberos. From there, the user or her script runs the server: an unprivileged process that chooses a random shared encryption key and begins listening on a UDP port. The server conveys the port number and key over the initial connection back to the client, which uses the information to start talking to the server over UDP.

    You open a SSH connection (client->server:22). This port is allowed on the firewall, it lets you through. But then the server decides to listen on UDP:(random port) and tells the client, back through the (encrypted) initial connection, which UDP port to contact. So you initiate a SSP UDP session on that port. How does the firewall knows it should let you through? Since the port number is communicated on an encrypted session, it doesn't have access to that information. So how does this work in a secure environment? The paper doesn't mention any mean for the server to communicate with the network which port its listening on.

    1. Re:Firewalls by jimicus · · Score: 2

      Welcome to Yet Another Protocol Devised By Academics Who Have Not Been Near a Real Network in Twenty Years, If Ever.

      Or YAPDBAWHNBNARNITYIE for short.

    2. Re:Firewalls by inject_hotmail.com · · Score: 2

      You open a SSH connection (client->server:22). This port is allowed on the firewall, it lets you through. But then the server decides to listen on UDP:(random port) and tells the client, back through the (encrypted) initial connection, which UDP port to contact. So you initiate a SSP UDP session on that port. How does the firewall knows it should let you through? Since the port number is communicated on an encrypted session, it doesn't have access to that information. So how does this work in a secure environment? The paper doesn't mention any mean for the server to communicate with the network which port its listening on.

      My guess is as good as anyone else's, but I surmise it does a bit of packet trickery. Once device A (behind firewall) is connected to device B (may/may not be behind firewall, but at least one port is open, 22 by default in this case), device A can create an SSH tunnel...they really are rather neat and VERY useful as a means of security. For example, I have webmin running on a server, but its port (10 000) is blocked by the firewall. Once I connect to SSH I can redirect packets to a certain IP:Port combo (device A's IP:Random Port#) to the servers local address (127.0.0.1) and new UDP port, and voila: hidden/secure/direct connection. One can even make a tunnel in the other direction, so that the server can connect to a remote device in the same manner, and any application won't realize that it's even connecting to anything outside of its network.

      Whomever thought of and implemented SSH tunnels is a master genius. I would shake his/her hand if I ever saw them.

  12. Re:Why was a fork necessary? by Anrego · · Score: 2

    Once something becomes widely used and stable, making drastic changes becomes next to impossible.

    That's why we went CVS -> SVN -> git. Too many people were using CVS to make the changes made in SVN. Too many people are using SVN now to fix the (very old and oft complained about) problems with SVN.

    See also NFS. There are issues with NFS that people have complained about for years.. and they will never be fixed for the same reason.

  13. Re:Less is More by phantomfive · · Score: 2

    When you're operating on a slow wireless connection with an already high amount of traffic on it, every bit counts.

    Um, then don't download SSH over a slow wireless connection? Download over a high-speed wired connection and side-load it onto your device.

    --
    "First they came for the slanderers and i said nothing."
  14. Re:UDP for a connection which has to -reliably- se by batrick · · Score: 2

    > It's kind of hard to do things like roaming using TCP because endpoint IPs can change.

    Bullshit. With UDP you have to abstract the connection so that the source IP can change. With TCP you can do the exact same fucking thing. Close the old socket when you get a connection attempt from a new client with the right handshake.

  15. Re:Why was a fork necessary? by batrick · · Score: 2

    Because writing a new RFC for the SSH protocol and then improving the current ubiquitous OpenSSH is an unheard of undertaking.

  16. Re:Why would I want this compatibility break? by A+nonymous+Coward · · Score: 2

    Let's see...

    I get reconnectability (which I already have, either by using a VPN or by using screen on the server), but now it's built-in.

    But now it's automatic.

    I get local echo so I have no clue whether my connection has been dropped -- but OTOH, this is great if you have the brain of a goldfish and so can't remember what you just typed for a couple seconds till it gets echoed back. I presume this is optional, so non-goldfish-brains can tell it to 'degrade' to be as useful as ssh.

    It also is automatic and shows what hasn't been echoed. Further, typing while lagging by a character or two is incredibly frustrating to almost all brains in existence. It's like listening to headphones which have a half second delay in what you said. Your brain simply freezes.

    I get better unicode support -- well, that one's cool, anyway.

    And it needs ssh for login, but also needs a mosh server -- so I can ssh into every server, but only mosh into a few.

    Am I missing some really great thing about it? It seems like a major hassle for a minor improvement.

    What a pessimist.

  17. Re:Missed from summary by vlm · · Score: 3, Interesting

    i can't see any idle traffic ... being specified

    I looked into MOSH in detail a little while ago and the keepalive packet is every 3 seconds or 3 packets per second can't remember which.

    It was often enough to make me pause... that's a lot of traffic if you're metered and paying by the K and/or powered by battery...

    --
    "Science flies us to the moon. Religion flies us into buildings." - Victor Stenger
  18. Roaming is not needed in mom's basement. by Medievalist · · Score: 2

    I see the need for this all the time. It's a commonplace in large enterprises like hospitals, factories, and financial services corporations.

    Example: I'm working on my hospital laptop. I get called urgently to do something elsewhere in the hospital so somebody won't die right now. I grab the lappie and run, then when I get to the theatre I plug into the malfing imager and fix it. Meanwhile all my SSH connections died because I crossed three wireless boundaries at high speed.

    Example 2: I'm on the line debugging the tension loader robot while a human continuously manually corrects the tension downthread. I find the upstream data to the robot is bad and I have to backtrack all the way across the building to find the malfunctioning sensor, then come back and double-check the robot again. All my SSH connections into the DCS keep failing because the factory floor's high RFI means we have to have lots of small loud wireless zones, and I have to keep moving among them.

    Example 3: I'm in a conference room lecturing junior banksters on how to fleece grandmothers and the CEO throws us out so his pet congressman can use the room to tongue-polish his shoes for him. The next conference room is two wireless zones away, so my secure SSH tunnel into Dr. Evil's antarctic lair fails and I have to sacrifice another day trader to get the blood I need for our in-house key transfer protocol.

    OK, that last example was a bit contrived but I was starting to get bored.

  19. Re:I stopped reading after this by Junta · · Score: 2

    Tmux's biggest claim is one of idealogy (BSD vs GPL) rather than any real technical merit.

    Actually, tmux defaults at least are nice. When I 'tmux a' to share a session with someone else, our multi-window view is synced. Fit-to-terminal is a bit more sane too.

    Screen developer/advocates really need to provide a guide on how to make screen behave like tmux default, if possible. Ctrl-A default bind is annoying as anything too.

    --
    XML is like violence. If it doesn't solve the problem, use more.
  20. Re:UDP for a connection which has to -reliably- se by agrif · · Score: 2

    Bullshit. With UDP you have to abstract the connection so that the source IP can change. With TCP you can do the exact same fucking thing. Close the old socket when you get a connection attempt from a new client with the right handshake.

    I'm a little out of my depth here, but I'd imagine it'd be much easier with UDP because UDP is connectionless. With this sort of roaming, the server isn't expected to change addresses, but the client is. So, have the client sign everything with a negotiated public key, and the server doesn't even have to care where each packet is coming from, or even open any new connections when the client moves across IPs.

    Since this is an SSH replacement, I'd expect the key signing to be done already, so once you build an ordering and reliability protocol on top of UDP you essentially get the roaming for free.

  21. Maybe not so good with completion by Anonymous Coward · · Score: 3, Insightful

    Modern shells have completion, and mosh is not going to predict that.

    It seems to me that for my typical usage it is going to have limited utility - I'm either in a shell where I'm leaning heavily on the tab for completion, or in vi where it would need to secondguess what vi is going to display.

  22. Re:I stopped reading after this by skids · · Score: 2

    Ctrl-A default bind is annoying as anything too.

    Yeah, always had issues with that. I always set to CTRL-G, since the only thing I ever use that key for is bailing out of thinkos in emacs, and double-pumping that in non-screen mode is pretty harmless.

    Plus, being an alarm key, it's more semantically correct.

  23. Re:UDP for a connection which has to -reliably- se by smellotron · · Score: 2

    I'm a little out of my depth here, but I'd imagine it'd be much easier with UDP because UDP is connectionless. With this sort of roaming, the server isn't expected to change addresses, but the client is. So, have the client sign everything with a negotiated public key, and the server doesn't even have to care where each packet is coming from, or even open any new connections when the client moves across IPs.

    In the context of persistent logical connections, you have to consider that the TCP connection will get severed and must be re-established. It's not enough to have an open connection sitting around; if bits aren't coming from the other side, the open connection may have been physically severed by some dead networking gear or a backhoe. So you end up coding some application-level heartbeat-and-reconnect logic with logic to securely resume a session (forgive the hand-waving here).

    At this point, if the "securely resume a session" bit is sufficiently compact, you are free to do the exact same logic per-packet, and you don't need to maintain a TCP connection. You lose TCP's reliable-ordering support, but the automatic-reconnect logic is typically sufficient to do without reliable-ordering. You also lose TCP's congestion control, so you'll probably need to add some application-level throttling mechanism to avoid DoSing yourself.

    This is why TCP vs. UDP is irrelevant in the topic at hand. Neither is sufficient to maintain a persistent connection, and the extra logic required on top of one can typically be ported to the other.

  24. Re:I stopped reading after this by jgrahn · · Score: 2

    And many (most?) SSH clients support auto-reconnect on short network drops.

    It's not even a case of reconnect. A TCP connection lasts forever or until one side says "stop"; all the client has to do is *not* explicitly time out after N seconds. Misconfigured NAT devices tend to fuck this up though; one of many reasons NAT is evil.