Skip to content

Instantly share code, notes, and snippets.

@jas-
Last active December 18, 2015 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jas-/5858980 to your computer and use it in GitHub Desktop.
Save jas-/5858980 to your computer and use it in GitHub Desktop.
SSH Automation
#!/bin/bash
# requires the sshpass binary from http://en.sourceforge.jp/projects/sfnet_sshpass/releases/
read -sp "Enter username: " user
read -sp "Enter password: " pass
read -sp "Enter command: " cmd
# define a list of machines
machines=array('192.168.1.10', '192.168.1.11', '192.168.1.12')
for i in "${machines[@]}"
do
sshpass -p ${pass} ssh -l ${user} -o StrictHostKeyChecking=no "${i}" "${cmd}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment