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:
- Connect a monitor & keyboard to your Raspberry Pi.
- Login as Pi
- run "sudo raspi-config"
- Select option "8 Advanced Options"
- Select "A4 SSH"
- Select <Enable>
- You should now get the message "SSH Server Enabled"
- Select "OK"
- 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).
- Install and open "JuiceSSH"
- Select "Connections"
- Select the + Button
- 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)
- Select your (new) connection
- If asked if you want to add the key press "Yes"
- 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.