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 bb076e7c6b Update README 3 weeks ago
bin Start porting Python version to Go 5 years ago
cmd ~/.ssh/ssh_config support and basic groups 3 weeks ago
debian ~/.ssh/ssh_config support and basic groups 3 weeks ago
.gitignore Release as .deb 3 weeks ago
README.md Update README 3 weeks ago
flags.go ~/.ssh/ssh_config support and basic groups 3 weeks ago
go.mod Release as .deb 3 weeks ago
go.sum Release as .deb 3 weeks ago
inventory.go Release as .deb 3 weeks ago
inventory_yaml.go ~/.ssh/ssh_config support and basic groups 3 weeks ago
known_hosts.go Fix known_hosts and inventory 3 years ago
makefile ~/.ssh/ssh_config support and basic groups 3 weeks ago
sftp.go Update README and some examples 2 years ago
ssh.go Release as .deb 3 weeks ago
ssh_config.go ~/.ssh/ssh_config support and basic groups 3 weeks ago
ssh_config_test.go ~/.ssh/ssh_config support and basic groups 3 weeks ago
utils.go ~/.ssh/ssh_config support and basic groups 3 weeks 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

Features:

  • Loads hostname aliases from ~/.ssh/config
  • Basic support for groups in YAML-inventories

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
  • Group support in INI-based inventories
  • Support group-trees (groups of groups)

Ansible inventories

Ansible INI-based and YAML-based configurations are supported to some degree, 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_ssh_host
  • ansible_port / ansible_ssh_port
  • ansible_user