The Remote Debugginator is a portable Raspberry Pi system that enables remote LAN access through a 3g connection.
It was developed for the Acacia Irrigation project.
- Raspberry Pi
- Make sure to buy a version 2 or higher, as it can provide more power to USB devices
- Power Supply, 2A or higher prefered.
- Case + Screen for RPi, Tontec 3.5 Inch Touch Screen used in testing.
- USB battery pack (10000 mAh), or larger.
- 3g USB dongle
- Here is a list of Linux compatible dongles
- Make sure to check for cell provider support
- Portable USB keyboard
- More options Here
- Digital Ocean instance
- M2M Sim card. Here are some providers:
- The Pi was set up using the default Raspbian distro, Download Here desktop version for graphical interface.
- Set up screen. See issue #1
- Connecting to wifi via command line
- Preventing Edimax wifi adapter from sleeping during shell sessions when idle
- Booting directly into shell
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
We run the 3g and tunnel shell scripts in separate screen windows. This makes it easier to debug should a problem occur.
- Install screen,
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install screen
Add this to ~/.screenrc
:
defshell -bash
multiuser on
acladd pi
This runs the run.sh
script on the Pi's terminal when it boots up.
Add to ~/.bashrc
:
if [ -n "$STY" ]; then
# Screen session
echo 'screen session'
elif [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
# SSH Session
# http://serverfault.com/a/506267
echo 'ssh session'
else
# Main session
echo 'main session'
~/run.sh
fi
Add to ~/.ssh/config
so that the client exits after error (usually it will hang) and disconnects after 3 x 60 seconds of unresponsiveness.
ExitOnForwardFailure yes
ServerAliveInterval 60
Generate an SSH key on the Pi by following the guide here. Then copy the Pi’s public key to >~/.ssh/authorized_keys
on the DigitalOcean server. This will let the Pi login to the server without a password.
Add this to sudo nano /etc/ssh/sshd_config
so that the connection times out after 3 x 60 seconds of unresponsiveness.
ClientAliveInterval 60
run.sh
3g.sh
tunnel.sh
sudo nano /boot/config.txt
and add,
max_usb_current=1
to the bottom. Save and exit, then reboot.
To connect to 3g, we’ll need to install Sakis3g, now seemingly defunct. You cand still get it by instlling UMTSKeeper. UMTSKeeper also helps by automatically reconnecting in the event of a connection failure. It’s a good idea to try UMTSKeeper first in interactive mode.
Test out the reverse tunnel by running this command on the Pi. You’ll want to replace the IP address with the address of your own server.
ssh -R 22222:localhost:22 ubuntu@<IP Address>
If this works, you can log into your server (using a separate terminal) and connect to the Pi via this command:
ssh -p 22222 pi@localhost
- If connected to the internet via usb internet sharing or some ethernet/RJ45 internet connection you can use a service to automatically tunnel to your debug server. Just install the following as a service, it will attempt a connection every 5 seconds after a network connection is established.
[Unit]
Description=Connect to Cloud Server
After=network-online.target
Wants=network-online.target
[Service]
User=pi
ExecStart=/usr/bin/ssh -g -N -T -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -R 22222:localhost:22 ubuntu@<IP Address>
StandardOutput=append:/tmp/ssh-service-log-out.log
StandardError=append:/tmp/ssh-service-log-err.log
# Restart every >2 seconds to avoid StartLimitInterval failure
RestartSec=5
Restart=always
[Install]
WantedBy=multi-user.target
Reverse tunneling errors: https://serverfault.com/questions/595323/ssh-remote-port-forwarding-failed
Look into this: https://mosh.mit.edu/#techinfo
How does reverse SSH tunneling work: https://unix.stackexchange.com/questions/46235/how-does-reverse-ssh-tunneling-work