Skip to content

Instantly share code, notes, and snippets.

@gajoseph
Last active November 16, 2020 22:13
Show Gist options
  • Save gajoseph/c8930d8a2c5aeb86ebf4aeb457781415 to your computer and use it in GitHub Desktop.
Save gajoseph/c8930d8a2c5aeb86ebf4aeb457781415 to your computer and use it in GitHub Desktop.
script verifies that the ssh and sudo functionalities are workng as expected
/*
This script verifies that the ssh and sudo functionalities are workng as expected
*/
sshme.sh:: contents are below
sshpass -p password ssh -tt -o LogLevel=error -q id@$host <<'EOF'
ls| wc -l
echo password | sudo -S su - postgres -c "ls|wc -l"
exit
EOF
### list of host names are stored in hosts.txt. contents are stored as below
SERV111
SEVR123
#######Run the command as below
while read line; do EXPORT host=$line; ./sshme.sh >> asdqwe.sh; done < hosts.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment