Mosh, Putty, and Cygwin (with a side of Cygputty)

After reading about Mosh (Mobile Shell) I had to give it a try.  This is truly SSH for the modern age.  Connections STAY connected even when your IP changes, or you roam from network to network.  You can put your laptop to sleep while connected, carry it to work, open it up, and the connection is still live.  Amazing!

  1. Mosh on the server(s)
    • This part is easy.   Follow the instructions from the Mosh site for your distro.  Since I’m running Ubuntu 12.04 it was as easy as “sudo apt-get install mosh” but it will vary from distro to distro.
    • You may have to open some holes in your firewall – I had to do a “sudo ufw allow proto udp to any port 60000:61000” to let Ubuntu listen on the req’d ports. 
    • You’ll also need SSH access to your server, as the initial authentication + initialization of the Mosh session is handled via SSH.
  2. Cygwin
    • Also Easy.  Download the setup.exe from Cygwin, and run it.  There are a few extra packages you’ll need in order to compile Mosh for Windows, so make sure you select:
      • make
      • boost
      • libncurses-devel
      • pkg-config
      • and perl
  3. Mosh for Cygwin
    • This bit requires some compiling, but don’t be nervous.  Step by step instructions are at Gisthub.  We’ve done steps 1+2 already, so start from 3.
  4. Putty (Or Kitty!)
    • Download and install Putty, or Kitty if you prefer.  Kitty is a fork of the most recent Putty with a bunch of new features – like transparency settings for the windows.
  5. PuttyCyg Plugin
    • If you use Putty then grab this, or if you’re on Kitty then grab this.  Extract it in the same folder as the Putty/Kitty executable.
  6. Putty profiles
    • Last stretch!  There are a few things you need to do here.
      1. First, you’ll need to add c:\cygwin\usr\local\bin\ and c:\cygwin\bin to your path. 
        1. Open the start menu
        2. right click on Computer
        3. Click Advanced System Settings
        4. Click the Environment Variables button on the Advanced tab
        5. Under System Variables select “Path” and add “;c:\cygwin\usr\local\bin\;c:\cygwin\bin” to the end.  MAKE SURE YOU DON’T DELETE ANY THING – JUST ADD THE CYGWIN PATHS TO THE END
      2. Now, open Putty/Kitty. 
      3. Select PuttyCyg as the connection type
      4. enter “mosh server.domain.com” as the command – where server.domain.com is the host you want to connect to.
      5. Hit Open
  7. You’re now connected via Most to your host thru Putty/Kitty!  Yay!  SSH that’ll stay connected no matter how you move about from IP to IP.