grapes
Lightweight tool designed to distribute commands over ssh with ease
About grapes
grapes

grapes is lightweight tool designed to distribute commands over ssh with ease.
Update (25/04/2019)
Handshake validation is now in place in order to fix CVE-2017-3204, The validation will use the built-in fingerprint list ~/.ssh/known_hosts as default.
In order to add your ssh server fingerprint to known_hosts run the following:
$ ssh-keyscan -H YOURHOST.COM >> ~/.ssh/known_hosts
Run with docker
docker run -v ~/.grapes.yml:/root/.grapes.yml -v ~/.ssh/id_rsa:/root/.ssh/id_rsa -it docker.pkg.github.com/yaronsumel/grapes/grapes:0.3.0
Installation
Run (Go v1.26+ required):
$ go install github.com/yaronsumel/grapes@latest
Usage
Example:
$ grapes -c config.yml -i ~/.ssh/id_rsa -s prod -cmd whats_up --async
- use the --help flag for full usage output.
Each command result includes its captured stdout and stderr under std.out and
std.err. An error field describes execution or session failures, and
exit_status records the remote exit status when available (including zero for
success). Stderr output alone does not mean that a command failed.
Grapes finishes reporting all selected servers before exiting, including in async mode. It exits with status 1 if any connection, command, or output write fails, and status 0 when all succeed. Commands continue after a nonzero remote exit; each result is reported separately. Failure summaries are written to stderr.
Connection setup has a 10-second limit covering DNS lookup, TCP connection, and SSH handshake/authentication. Each command has a separate 5-minute limit covering session setup, execution, output collection, and session cleanup. Both limits apply in sequential and async mode and can be changed using positive durations:
$ grapes -s prod -cmd whats_up -y --connect-timeout=20s --command-timeout=15m
On a timeout, grapes closes that server's SSH connection, reports the timeout with any captured output, and exits with status 1 after reporting all servers. Remaining commands on that server are marked as skipped; other servers continue. Closing the connection does not guarantee termination of detached remote processes.
Config
config structure (YAML):
version: 1
servers:
prod :
- name : "prod server #1"
host : "prod.example.com:22"
user : "ubuntu"
staging :
- name : "staging server #1"
host : "staging.example.com:22"
user : "ubuntu"
- name : "staging server #2"
host : "staging.example.com:23"
user : "ubuntu"
commands:
whats_up :
- "ls -al /tmp"
- "date"
date :
- "date"
Tests
$ go test -race ./...
The SSH tests use a local test server and do not require access to a public server.
Written and Maintained by @YaronSumel
Frequently Asked Questions
What is grapes?
grapes is a Software Packages library for the Go programming language. Lightweight tool designed to distribute commands over ssh with ease
How do I install grapes?
Install grapes with the Go module system using `go get yaronsumel/grapes`. Check the repository for the current installation instructions.
What category does grapes belong to?
grapes is listed under Software Packages, specifically DevOps Tools.