Using Android to securely command & control your projects!



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:

cd /data/.ssh/
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:
5e:f5:7e:71:ec:2d:2c:46:02:9d:3e:89:4a:3a:b7:b6 Name

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/ root@OtherDevicesIP:.ssh/
ssh root@OtherDevicesIP ‘cat .ssh/ >> .ssh/authorized_keys

For OpenWrt do this:

scp /data/.ssh/ root@OtherDevicesIP:/etc/dropbear/
ssh root@OtherDevicesIP ‘cat /etc/dropbear/ >> /etc/dropbear/authorized_keys

4.Make a script


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!


Posted on


Submit a Comment

Your email address will not be published.

Pin It on Pinterest

Share This