Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mxssl/cmd-runner
Execute commands on remote hosts asynchronously over ssh
https://github.com/mxssl/cmd-runner
configuration go golang ssh
Last synced: 2 months ago
JSON representation
Execute commands on remote hosts asynchronously over ssh
- Host: GitHub
- URL: https://github.com/mxssl/cmd-runner
- Owner: mxssl
- License: apache-2.0
- Created: 2018-07-01T15:31:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-16T11:15:06.000Z (over 6 years ago)
- Last Synced: 2024-08-10T11:02:32.359Z (6 months ago)
- Topics: configuration, go, golang, ssh
- Language: Go
- Homepage:
- Size: 1.57 MB
- Stars: 24
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cmd-runner
Execute commands on remote hosts asynchronously over ssh
## Installation
Download compiled binary for your system
[Linux](https://github.com/mxssl/cmd-runner/releases/download/0.0.4/cmd-runner-linux-amd64)
[MacOS](https://github.com/mxssl/cmd-runner/releases/download/0.0.4/cmd-runner-darwin-amd64)
Example
```bash
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
```## How to run
### Usecase 1
#### Run commands from local file
1. Create config file - `config.toml`
Example:
```toml
# 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"
```2. Create file with commands that you want to run on remote hosts - `commands.txt`
Example:
```bash
apt-get update
apt-get upgrade -y
```3. 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`
### Usecase 2
#### Copy local file to remote hosts
1. The same as `Usecase 1`
2. Start program `cmd-runner copy`
### Usecase 3
#### Combine Usecase 1 and Usecase 2
You can copy bash script to remote hosts with `cmd-runner copy` and run this script with `cmd-runner start`