Android - Are there any command line SSH clients available for rooted Android phones?
Since my original question was about an ssh binary, and there is an answer for that, I'll accept that answer. However, there is another way to do what I wanted to do, kinda, that might be interesting to someone some day.
Tasker + ConnectBot can be used to execute arbitrary remote (or local, I guess, but Locale Execute is better for that) commands on a schedule.
Step 1: Set up your connection in ConnectBot.
- You can have duplicate connections in ConnectBot as long as they have different aliases. You have to rename one first (away from user@host) in order to create the second. Long Press and select "Edit Host" to perform these changes.
- You probably want to set up an ssh key without a password so that you can use this for automation.
- Once the connection actually works, you can use "Post-login automation" to add the remote commands you would like to run. Make sure there is a blank line at the end so that enter is sent after your last command. Use enter or ; to separate commands. I suggest using something like "echo hello" as a test until you are sure things are working, and "exit" at the end if you don't want to leave the connection open.
- Test this in isolation.
Step 2: Create a Tasker Task to call connectbot.
- Create a new Task in Tasker.
- Add an Action. From Misc, select "Action Intent"
- The fields are:
- Action: android.intent.action.VIEW
- Cat: Default
- Data: ssh url, in the form of "ssh://user@host/#alias" (without the quotes). The alias, user and host here must match the alias you set up in Step 1.
- Target: Activity
- Click Test. Connectbot should open and your commands should execute on the remote host.
Step 3: Use this Task in Tasker however you would normally.
You can install the Terminal Emulator from google. Alternatively there is the Better Terminal Emulator Pro. I tried the Terminal Emulator on a non-rooted phone and it seemed to work fine.
Better Terminal Emulator Pro includes the dropbear ssh client, which can be launched from the command line or via a launcher. More info from the authors.
I know it's an old thread but wanted to +1 the comment about BTEP
I'm also using BTEP's ssh binary though I just call it from it's path instead of linking it /data/data/com.magicandroidapps.bettertermpro/bin/ssh [email protected]
or generate a pair of keys and use public key authentication /data/data/com.magicandroidapps.bettertermpro/bin/ssh -i /data/data/com.magicandroidapps.bettertermpro/home/.ssh/id_rsa -l root 192.168.1.1
I use the above command from SL4A r4 in various scripts and it works fine :)
before I could do this I needed to chmod a+x /data/data/com.magicandroidapps.bettertermpro/home/.ssh
once this is done and you backup/restore BTEP with TitaniumBackup the permissions are kept this means if you flash a new rom you can just restore the apps and all your scripts will work again