-
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).
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"
}, {
"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. Mandatory. |
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 confirm before command execution. Optional, defaults to false . |
Format
Each configuration file must be an UTF-8/16/32 encoded text file with .json
extension.