Introduction: Using Android Ssh Shortcuts to Securely Control Your Linux 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.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: 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:
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
Step 2: 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!
Step 3: 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!