Parallel SSH utilities
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ben de Graaff 88fde0b283 Update README and some examples 4 months ago
bin Start porting Python version to Go 3 years ago
cmd Update README and some examples 4 months ago
README.md Update README and some examples 4 months ago
flags.go Update README and some examples 4 months ago
go.mod Update README and some examples 4 months ago
inventory.go Support and prefer yaml inventories 5 months ago
inventory_yaml.go Support and prefer yaml inventories 5 months ago
known_hosts.go Fix known_hosts and inventory 1 year ago
sftp.go Update README and some examples 4 months ago
ssh.go Update README and some examples 4 months ago
utils.go Fix known_hosts and inventory 1 year ago

README.md

sshutils

Parallel SSH utilities with support for Ansible-like inventory files.

  • pssh: execute commands
  • prun: execute local scripts/binaries remotely (requires SFTP support)

Requirements:

  • A running ssh-agent with the proper keys loaded
  • The public key of the server is in ~/.ssh/known_hosts

Examples

Run an apt update and check the effects:

pssh -i hosts.yaml all sudo env DEBIAN_FRONTEND=noninteractive apt-get update
pssh -i hosts.yaml all sudo env DEBIAN_FRONTEND=noninteractive apt-get --simulate dist-upgrade

Run a local script (or binary) remotely:

$ cat myscript.sh
#!/bin/sh
echo "$@"
$ prun -i hosts.yaml all ./myscript.sh hello world
cat> hello world
dog> hello world

TODO

  • Additional documentation
  • pscp: parallel transfer
  • Load hostnames from ~/.ssh/config
  • (Non-)inventory support
    • Groups
    • Assume hostname if name not in inventory and no glob char

Ansible inventories

Ansible YAML-based configurations are supported, for example:

all:
  hosts:
    # Set required variables per host:
    dog: {ansible_host: dog.example.com}
    cat: {ansible_host: cat.example.org}
  vars:
    # Variables can also be set globally
    ansible_user: admin

Supported variables:

  • ansible_host
  • ansible_port
  • ansible_user