First I created the ARM ELF binary: myrintdata is the file created using agcc (http://plausible.org/andy/agcc):
export LD_LIBRARY_PATH=/root/download/android/sync/ndk/build/platforms/android-8/arch-arm/usr/lib/:$LD_LIBRARY_PATH
export PATH=/sde3/root/download/android/sync/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin:$PATH
agcc myprint.c
mv a.out myprintdata
Next we will try to scp from inside the Android device to the host environment. All the ssh/scp utilities is in the dropbear directory….but difficult/impossible to work:
# cd /data/data/berserker.android.apps.sshdroid/dropbear/
# ./scp root@10.10.1.155:/root/download/android/myprintdata /sdcard
/system/bin/ssh: No such file or directory
lost connection
# ls /system/bin/ssh
/system/bin/ssh: No such file or directory
# echo $PATH
/data/data/berserker.android.apps.sshdroid/dropbear:/usr/bin:/usr/sbin:/bin:/sbin:/system/sbin:/system/bin:/system/xbin:/system/xbin/bb:/data/local/bin
# ls /data/data/berse*/dropbear/ssh
/data/data/berserker.android.apps.sshdroid/dropbear/ssh
# ls /data/data/berse*/dropbear/scp
/data/data/berserker.android.apps.sshdroid/dropbear/scp
So we know that ssh and scp all exists in the Dropbear directory – but since it is the $PATH directory, and the binaries not using the $PATH environment variable to look for the command (eg scp and ssh and sftp), this means that the binaries actually hardcode the other binaries in the standard path (/system/bin). Another alternative to transfer file is needed.
# cp ssh /system/bin/
cp: not found
as noted….Android does not have “cp” command.
# dd if=scp of=/system/bin/scp
/system/bin/scp: cannot open for write: Read-only file system
Yes, dd can be used…but not in the /system directory.
Finally doing a scp from outside the Android environment (ie, host env):
Copy from outside into the Android devices (and it worked):
scp myprintdata root@10.10.1.160:/data
Copy from inside the Android devices to outside (and it worked):
scp root@10.10.1.160:/sdcard/ls.log.gz .
After we copied the binary “myprintdata” to /sdcard or /data directory – executing it immediately worked!!!!
Why do I have to use SSHDroid to connect to the Android device? Basically because this Samsung device I have is not able to communicate with my Linux laptop via USB at all – but another different Samsung phone is able to – most likely it is hardware problem, as both have been setup in the same way.
Posted by Jaap Halo on April 9, 2013 at 2:58 am
I user also Servers Ultimate which also has 40 other servers beside SSH.
It can be found here:
https://play.google.com/store/apps/details?id=com.icecoldapps.serversultimate