If you make internet connected stuff based on Linux/GNU and own a Android device powered by CyanogenMod rejoice! This is a safe(as safe as it gets) way to control your projects, so unlock your home to your friends while miles away, start a car(or don’t), securely wipe all of your disks with one touch, feed the cats, or just turn your lights on and off.
All you need is:
1x rooted Android device
1x sl4a scripting layer for android
1x project that supports ssh with a dyn-dns setup on ssh port if you want direct access from the internet,and not only from wifi.
And this is how to make it work:
1.Download sl4a scripting layer for android from here.
Enable install from unknown sources on your device and instal the apk.
2.Generate public and private keys
Open terminal emulator:
ssh-keygen -t rsa -C “Name”
You should see:
Generating public/private rsa key pair.
Enter file in which to save the key:
Press ‘Enter’ here to accept the default.
Enter passphrase (enter strong passphrase):
Enter same passphrase again:
The key fingerprint is:
3.Copy public keys to device you wish to control:
If you use most linux distro’s you’ll have to do it this way:
scp /data/.ssh/name_id_rsa.pub root@OtherDevicesIP:.ssh/
ssh root@OtherDevicesIP ‘cat .ssh/name_id_rsa.pub >> .ssh/authorized_keys
For OpenWrt do this:
scp /data/.ssh/name_id_rsa.pub root@OtherDevicesIP:/etc/dropbear/
ssh root@OtherDevicesIP ‘cat /etc/dropbear/id_rsa_name.pub >> /etc/dropbear/authorized_keys
Tap on menu button and than add shell:
Name the script and add command:
su -c “ssh -i /data/.ssh/name_id_rsa root@OtherDeviceAddress ‘command'”
Press menu button, then save&run!
Input yes when prompted to save host in known_hosts, and close terminal when prompted.
If you are conecting over dynamic dns than you must delete the IP address from /data/.ssh/known_hosts to end further suffering when the IP changes!
5. Add a shortcut to homescreen:
Add a new widget to the phone wall, search for sl4a scripts and add. It will let you choose the script and background or forground way of executing it; choose the background one and repeate the process for every command you wish to add! And that’s it!