Run commands across servers using ssh
Sshrunner runs an ssh command across multiple servers
Usage:
sshrunner [flags]
Flags:
-s, --agentsocket string Socket for the ssh agent (default "/private/tmp/com.apple.launchd.xxx/Listeners")
-c, --command string Command to run
--config string config file (default is $HOME/.sshrunner.yaml)
-h, --help help for sshrunner
-k, --key string Ssh key to use for authentication, full path (default "/Users/raravena/.ssh/id_rsa")
-m, --machines strings Hosts to run command on
-p, --port int Ssh port to connect to (default 22)
-a, --useagent Use agent for authentication
-u, --user string User to run the command as (default "raravena")
Makes /tmp/tmpdir in 17.2.2.2 and 17.2.3.2:
$ sshrunner -c "mkdir /tmp/tmpdir" -m 17.2.2.2,17.2.3.2
Creates /tmp/file file in host1 and host2
$ sshrunner -c "touch /tmp/file" -m host1,host2
Moves a file and creates another one in host1 and host2:
$ sshrunner -c "mv /tmp/file1 /tmp/file2; touch /tmp/file3" -m host1,host2
Runs with default in ~/.sshrunner.yaml
$ sshrunner
Sample ~/.sshrunner.yaml
sshrunner:
user: ubuntu
key: /Users/username/.ssh/id_rsa
useagent: true
machines:
- 172.1.1.1
- 172.1.1.2
- 172.1.1.3
- 172.1.1.4
- 172.1.1.5
command: sudo rm -f /var/log/syslog.*