Introduction: Installing Mosh & Enabling Port Forwarding

Mosh is a replacement for your SSH session to your Raspberry Pi. Using Mosh you can work more reliable over cellular data. If the connection is lost Mosh will attempt to reconnect to your pi automatically, most of the time without you noticing.

See https://mosh.mit.edu/ for more details on Mosh.

Step 1: Enable SSH

If you have SSH enabled you can skip this step.

Instructions on how to enable SSH on your raspberry pi can be found here or below:

  1. Connect a monitor & keyboard to your Raspberry Pi.
  2. Login as Pi
  3. run "sudo raspi-config"
  4. Select option "8 Advanced Options"
  5. Select "A4 SSH"
  6. Select <Enable>
  7. You should now get the message "SSH Server Enabled"
  8. Select "OK"
  9. Select "Finish"

Step 2: Install Mosh

Open a SSH session to your Pi and/or do this on the local command line (with screen and keyboard).

Note: If you did the previous step you ended up on the command line.

Run "sudo apt-get install mosh" (without quotes)

Your Raspberry Pi will now start installing Mosh. (It might be possible that it asks for a confirmation, just answer with "y" and "Enter".) Wait now for the command-prompt to reappear.

Step 3: Test Your Mosh Connection

For this part I used JuiceSSH (android, play store).

  1. Install and open "JuiceSSH"
  2. Select "Connections"
  3. Select the + Button
  4. Enter the details
    • Enter a nickname (optional)
    • Set the type to "Mosh"
    • Enter the IP address from your Raspberry Pi is the address
    • Create a new identity
      • Enter the Username (pi)
      • Tap the V (top right)
    • Tap the V (top right)
  5. Select your (new) connection
  6. If asked if you want to add the key press "Yes"
  7. Enter the password for the pi user

You should now be connected.

Step 4: Add the Port-forwards to Your Router

So if this all worked you can now proceed with the router settings.

WARNING: Before proceeding make sure your pi has a strong password, otherwise hackers might be able to enter access your device!!

Open your browser and go here: http://portforward.com/english/applications/port_f...

What you'll need to to forward is the following ports:

  • SSH: WAN TCP port 22 to LAN TCP port 22
  • SSH: WAN UDP port 60000-60010 to LAN UDP port 60000-60010

Step 5: Test the Connection

Repeat step 3 but instead of the local IP of your Raspberry Pi enter the WLAN IP.

The WLAN IP is listed on the portforward site. (top-right)

Connect to a external connection (via a Cellular connection or another external connection) and test the connection.

Comments

author
seamster made it!(author)2015-05-30

Nicely done. Thanks for sharing this!