Saturday, May 3, 2014

How to setup keybased ssh, scp to Transend WifiSD card

The following are steps to get root and ssh access to Transend WifiSD card to automate copying of files from the card. It is assumed that the user is familiar with some knowledge of Linux scripts and commands. It is also assumed that the user is going to use a Linux host to interact with the card although the setup can be easily used in Windows as well using tools like winSCP or cygwin or pscp.exe.

The setup outlined here is based on the information and code shared by the original author (Glen) at the following link/blog.

DISCLAIMER: Use it at your own risk. I am not responsible for any loss or damage to your property.


0. Use the Transcend tools (andriod app or ios app) to configure your card to connect to your home wifi network; while you are at it, change admin user, cards wifi ssid, passwd etc. Make sure your card successfully connects to your  wireless network and note the IP address assigned to it by your home wifi router.

1. Download and extract in your desktop computer and edit the file to uncomment the line below for telnet access, i.e. remove '#'

   telnetd -l /bin/bash &

2. Edit the file and change "trusted_network" variable to match yours

   example: trusted_network="myrouterssid:"
3. Insert your SD card in your computer and copy the entire custom/ directory from step #1 above to the root directory of SD card. In addition, also copy to root directory of SD card.

4. Remove card and reinsert it into your computer.

5. Now you should be able to telnet to your card from your linux box, i.e. telnet <your_card_ip>
In the examples shown below is my WifiSD card  and 192.168.yyy.yyy is my ubuntu desktop

   arul@cheetah:~$ telnet
   Connected to
   Escape character is '^]'.
   # ls
   bin             home            lost+found      sbin            usr
   config_value    init            mnt             sys             var
   dev             lib             proc            tmp             www
   etc             linuxrc         root  

6. Once you are logged in via telnet as shown at #5 above, you need to create dropbear hostkeys and copy them to your desktop to include in /custom directory on SDcard.  Note: I have included two dummy files in /custom directory you need to replace them by creating your own key files. i.e. follow the example below but use your IP address and your user name of course.
   # dropbearkey -t rsa -f /tmp/dropbear_rsa_host_key
   # dropbearkey -t dss -f /tmp/dropbear_dss_host_key
   # scp /tmp/dropbear_* arul@192.168.yyy.yyy:/tmp/.
Now, copy the 2 files from your /tmp directory to the custom/ directory on the SD card  by replacing them.

7. Create (or copy if you already have a dsa public key) in your desktop to  the /custom directory as authorized_keys. Note: I have a dummy authorized_keys  file that you need to replace.

   ssh-keygen -t dsa
   cp ~/.ssh/ custom/authorized_keys

8. Once you update all the key files in custom/ directory in the card, unplug your card and plug it back into your device (computer or camera) one last time. Once the card boots, you should be able to ssh into your card or scp files, or setup automated scripts to copy files from card to your desktop... and pretty much do everything you can do with ssh!
   arul@cheetah:/tmp$ ssh
   # cat /proc/cpuinfo 
   Processor : ARM926EJ-S rev 5 (v5l)
   BogoMIPS : 421.06
   Features : swp half fastmult edsp java 
   CPU implementer : 0x41
   CPU architecture: 5TEJ
   CPU variant : 0x0
   CPU part : 0x926
   CPU revision : 5

   Hardware : KeyASIC Ka2000 EVM
   Revision : 0000
   Serial : 0000000000000000
   # date
   Sat May  3 16:13:53 UTC 2014
   # /sbin/busybox-armv5l uname -a

   Linux (none) #137 PREEMPT Fri Mar 22 18:21:52 CST 2013 armv5tejl GNU/Linux

   # exit
   Connection to closed.

   arul@cheetah:/tmp$ scp -r* .
   DSCN0254.JPG                                          100%  836KB 278.8KB/s   00:03 

Have fun with ssh/scp on your Transend WifiSD card!

   This is where I got the prebuilt busybox and dropbear binaries for reference. They are already in the custom/ directory for convenience.
   arm5l busybox:
   arm5l dropbear:

No comments:

Post a Comment