Created
March 10, 2015 16:35
-
-
Save jkanclerz/457b002eacc7d101b368 to your computer and use it in GitHub Desktop.
Remote Command Execution by ssh
This file contains hidden or 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
| #!/bin/bash | |
| echo "deploy Was started" | |
| hostname -f; | |
| uptime; | |
| for package in $@ | |
| do | |
| echo $package | |
| if [ "$(rpm -qa | grep -E "^$package")" != "" ] | |
| then | |
| echo 'jest' | |
| sudo yum reinstall -y $package | |
| else | |
| echo 'niema' | |
| sudo yum install -q -y $package | |
| fi | |
| done |
This file contains hidden or 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
| #!/bin/bash | |
| HELLO="world" | |
| ssh [email protected] bash -c "' | |
| ls | |
| pwd | |
| if true; then | |
| echo $HELLO | |
| else | |
| echo "This is false" | |
| fi | |
| echo "Hello world" | |
| sudo ls -la /root | |
| '" |
This file contains hidden or 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
| #!/bin/bash | |
| #ls -la; | |
| echo $1 | |
| #sudo ls -la /root; | |
| for n in {1..5}; do echo "I am executed remotly"; done | |
| hostname -f |
This file contains hidden or 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
| #!/bin/bash | |
| SERVERS=$(cat serv.txt) | |
| for host in $SERVERS | |
| do | |
| echo $host | |
| ssh $host 'hostname -f; uptime;' | |
| done |
This file contains hidden or 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
| #!/bin/bash | |
| SERVERS=$(cat serv.txt) | |
| PACKAGES=$(cat package.txt) | |
| for host in $SERVERS | |
| do | |
| echo $host | |
| cat deploy.sh | ssh $host "cat > /tmp/script ; chmod 755 /tmp/script ; /tmp/script $PACKAGES; rm -f /tmp/script;" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment