Skip to content

Instantly share code, notes, and snippets.

@Niraj-Fonseka
Created July 16, 2018 05:17
Show Gist options
  • Save Niraj-Fonseka/bd9ae7637c9722fca5bd50ac15477577 to your computer and use it in GitHub Desktop.
Save Niraj-Fonseka/bd9ae7637c9722fca5bd50ac15477577 to your computer and use it in GitHub Desktop.
ssh_shell_script.sh
#!/bin/bash
SCRIPT="cd "
HOSTS=("192.168.0.11")
USERNAMES=("username")
PASSWORDS=("password")
for i in ${!HOSTS[*]} ; do
echo ${HOSTS[i]}
SCR=${SCRIPT/PASSWORD/${PASSWORDS[i]}}
sshpass -p ${PASSWORDS[i]} ssh -l ${USERNAMES[i]} ${HOSTS[i]} "${SCR}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment