TTKAgent is a lightweight agent designed to facilitate communication between an MQTT broker and a local system. It subscribes to MQTT topics to receive commands, executes them on the local system, and publishes the output back to the MQTT broker. It provides flexibility in configuration and ensures basic security through authorization.
- Command Execution: Listens to MQTT commands and executes them on the local system.
- Authorization: Requires a key for command authorization, ensuring secure command execution.
- Output Publication: Publishes command output (result or error) back to the MQTT broker.
- Flexible Configuration: Can be configured via command line flags or a JSON configuration file.
- Daemon Mode: Optionally runs as a daemon for background operation.
- Go (Golang) installed on your system.
- Access to an MQTT broker.
-
Clone the TTKAgent repository to your local machine:
git clone https://github.com/TTKLabs/TTKAgent.git
-
Navigate to the project directory:
cd TTKAgent
-
Ensure you have Go modules enabled:
export GO111MODULE=on
-
Use the provided builder script to compile the code for multiple platforms. Ensure the script is executable:
chmod +x build.sh
-
Install the required packages
go get github.com/eclipse/paho.mqtt.golang; go get github.com/sevlyar/go-daemon
-
Run the builder script to compile the code:
./build.sh
-
Once the compilation process is complete, you'll find the compiled binaries in the
build
directory.
You can configure TTKAgent using either command line flags or a JSON configuration file.
Use the following command line flags to configure TTKAgent:
-u, --username
: MQTT broker username.-p, --password
: MQTT broker password.-b, --mqttbroker
: MQTT broker address.-m, --maintopic
: Main MQTT topic.-k, --key
: Key for command authorization.-d, --daemon
: Run as daemon (true/false).
Example:
./TTKAgent -u <username> -p <password> -b <mqtt_broker_address> -m <main_mqtt_topic> -k <key> -d
Alternatively, you can provide a JSON configuration file with the following fields:
- username: MQTT broker username.
- password: MQTT broker password.
- mqttbroker: MQTT broker address.
- maintopic: Main MQTT topic.
- key: Key for command authorization.
- daemon: Run as daemon (true/false).
Example JSON configuration file (config.json
):
{
"username": "<username>",
"password": "<password>",
"mqttbroker": "<mqtt_broker_address>",
"maintopic": "<main_mqtt_topic>",
"key": "<key>",
"daemon": true
}
To use the JSON configuration file, pass it as a command line argument:
./TTKAgent -c config.json
Use the TTKAgent with care, especially when interacting with sensitive systems. Ensure that the MQTT broker is properly secured to prevent unauthorized access to execute commands.
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
This project is licensed under the BSD License.