Skarafaz edited this page Sep 24, 2016 · 18 revisions

Usage

Mercury-SSH reads configuration data from standard JSON files saved on the device's external storage. Simply put your configuration files into the folder named Mercury-SSH on the device's external storage and you are ready to go.

Requirements

Mercury-SSH needs nohup and sudo to be installed on the target server to work properly. If these binaries are located in some exotic places outside of the execution PATH, you can specify their path using nohupPath and sudoPath optional server properties (see next section for details).

Authentication

Public key authentication is the preferred authentication method used by Mercury-SSH. If public key authentication fails then a password will be prompted. You are free to embed the password in the configuration file or type it each time you send a command (note that sudo commands will always require password in order to be executed, even with public key authentication).

Mercury-SSH uses a self generated 2048 bit RSA key. You can export the public key to sdcard and manually copy it to your server or let Mercury-SSH do this for you using the send public key feature (you still need password access to the target server to do this).

Writing a configuration file

Few lines of code are better than thousand words, so let's start with a sample configuration file:

{
    "name" : "My server",
    "host" : "192.168.0.1",
    "port" : 22,
    "user" : "user",
    "password" : "12345678",
    "nohupPath" : "/opt/bin/nohup",
    "commands" : [ {
        "name" : "Restart apache",
        "sudo" : true,
        "cmd" : "service apache2 restart",
        "confirm" : true
    }, {
        "name" : "Rsync",
        "sudo" : true,
        "cmd" : "rsync -a --delete /src/ /dst/"
    } ]
}

As you can see, a configuration file wrapps all the information you need to connect to a remote server and all the commands you want to send to it into a JSON object. The structure of this object is quite simple and is summarized below.

Server property summary

Property Type Notes
name string Friendly name (used as label). Optional, defaults to "Server".
host string Target hostname or IP address. Mandatory.
port integer Target port (1-65535). Optional, defaults to 22.
user string Login user. Mandatory
password string Login password. Optional.
nohupPath string nohup binary path. Optional, defaults to nohup.
sudoPath string sudo binary path. Optional, defaults to sudo.
commands array An array of objects defining available commands for the server. Optional.

Command property summary

Property Type Notes
name string Friendly name (used as label). Optional, defaults to "Command".
sudo boolean State if the command needs to be executed as root. Optional, defaults to false.
cmd string The command itself. Mandatory.
confirm string Ask for confirmation before sending command. Optional, defaults to false.

Format

Each configuration file must be an UTF-8/16/32 encoded text file with .json extension.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.