SSH Plugin


SSH Plugin is a tasker plugin that allows you to remotely connect to a server via SSH, and execute a command. Please note that you need to have Tasker installed in order to use this app.

Use Cases

Some possible use cases:


Connection

In the connection field you must use the format username@host:port (port is optional, and will default to 22 if not specified). You may use a tasker variable that will be substituted upon execution of the task. An example would be %username@%host:%port and when the task is executed whatever is stored in those variables will be used to connect.


Authentication


Password

A password can be used for authentication when logging into a server, but is not recommended. Technically your password will be stored as cleartext in your task of tasker, normally the password cannot be accessed aside from the plugin that created, but keep in mind that if you turn on logging in tasker your password can be passed into logcat and be picked up by other applications.


Keyfile

Keyfiles are the recommended authentication method, because the authentication cannot be logged via tasker. The best method would be to encrypt the keyfile and use a non-common password for the encryption passphrase. Keyfiles must be in openssh format currently, keyfiles from connectbot cannot be used currently.
Linux:
ssh-keygen -t rsa
Copy keyfile to phone.
Windows:
Use puttygen to generate and save a keyfile, then copy to phone.


Command

This is what will be executed on the remote server. Please note that sudo and su will no inherently work. If you wish to execute a command that would normally require root you need to either change the command via sudo chmod a+s /bin/command, or add it to the NOPASSWD of the sudoers file. Here is an example of how to do that.


Variables


Variable returned by plugin.

A Variable can be returned by the plugin that can be acted upon as soon as the remote commands have been finished executing on the remote server. To do this check the checkbox that says "Return Output" and input a variable name.
Please note that the variable name must begin with a % and be all lowercase. If you input an incorrect variable it will be corrected automatically for you, but your task needs to reflect the proper variable. Also note that the variable will only be accessible during the task so if you need it afterwards you will need to set it to a new upper-case varible within your task.
Only the output of the last command will be set into the variable.


Variables in the commands.

You may use tasker variables within the command field as well as the connection field. Upon execution of the task the current tasker variable will be substituted into the command.


Security

It is best not to store any password in the tasker task, or within the plugin. If you do opt to use a password instead of a keyfile it might be possible for other apps to pick up and store your password. Also it is a very bad idea to put a password of any kind into the command field, because it is trivial for anybody to edit your task to view the password.


Windows

While windows doesn't have ssh support by default it is possible to add openssh to windows. The processes is pretty involved and I don't recommend it unless you like messing around with the terminal and windows services a lot.

The version that works the best is the mls version of openssh. For windows copies 7 and below you should be able to just run that and be good, but if you have windows 8+ then you will need to install cywin and chgrp of the openssh directory to Users. After that you will need to change the openssh service to execute as your user instead of the local account.


Libraries used:

jsch from JCraft
aFileChooser by Paul Burke
Tasker by Pent
Locale plugin code by two forty four a.m.