Created
July 20, 2017 20:52
-
-
Save visitbethel/856381d65dbde5a5c6f3109b0bc50f8b to your computer and use it in GitHub Desktop.
sledgehammer distributed command with sudo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dsh ls /etc/bashrc | perl -ne 'BEGIN { printf "export ss=\${1};shift;export args=\$@;" }{ $_=~s/://g;@x=split /\s+/;printf "ssh -t %s \"echo \${ss} | sudo -S -u tibcosilver \${args} \"\n",$x[0], $x[2]}' | tee out | |
perl -i -pe "s/#/'/g" out | |
echo "Please run: . out [Password]" | |
Will generate something like this: | |
ssh -t vangrant1.com "echo ${ss} | sudo -S -u appuser ${args} " | |
ssh -t vangrant2.com "echo ${ss} | sudo -S -u appuser ${args} " | |
Then can be used like this | |
$ . out [sshpassword] [anycommand] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment