Execute commands on remote hosts asynchronously over ssh
Download compiled binary for your system
Example
wget https://github.com/mxssl/cmd-runner/releases/download/0.0.4/cmd-runner-linux-amd64 -O cmd-runner
mv cmd-runner /usr/local/bin/cmd-runner
chmod +x /usr/local/bin/cmd-runner/cmd-runner
- Create config file -
config.toml
Example:
# Credentials
username = "root"
password = "password"
# SSH private and public keys
ssh_private_key = "/home/user/.ssh/id_rsa"
ssh_public_key = "/home/user/.ssh/id_rsa.pub"
# SSH port
ssh_port = "22"
# Connection method: "key" or "password"
connection_method = "key"
# Remote hosts
hosts = [
"1.1.1.1",
"2.2.2.2",
"3.3.3.3"
]
# File with commands for "cmd-runner start" command
commands_file = "commands.txt"
# > Full < source and destination path to file for "cmd-runner copy" command
source_path = "/opt/scripts/script.sh"
destination_path = "/tmp/script.sh"
- Create file with commands that you want to run on remote hosts -
commands.txt
Example:
apt-get update
apt-get upgrade -y
- Start program
cmd-runner start
If you want files with stdout per host then start cmd-runner
with key:
cmd-runner start --file
cmd-runner
will create files hostname-output.txt
-
The same as
Usecase 1
-
Start program
cmd-runner copy
You can copy bash script to remote hosts with cmd-runner copy
and run this script with cmd-runner start