-
Notifications
You must be signed in to change notification settings - Fork 20
Home
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.
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).
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).
Few lines of code are better than thousand words, so let's start with a sample configuration file:
{
"name" : "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",
"shellPath" : "dash",
"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. |
sudoNoPasswd |
boolean | Set it to true if user is allowed to call sudo with no password. Optional, defaults to false . |
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 . |
shellPath |
string | Target shell binary path; the command will be executed by the specified shell. Optional, defaults to "sh" . |
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.