Skip to content

Instantly share code, notes, and snippets.

@jkanclerz
Created March 10, 2015 16:35
Show Gist options
  • Select an option

  • Save jkanclerz/457b002eacc7d101b368 to your computer and use it in GitHub Desktop.

Select an option

Save jkanclerz/457b002eacc7d101b368 to your computer and use it in GitHub Desktop.
Remote Command Execution by ssh
#!/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
#!/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
'"
#!/bin/bash
#ls -la;
echo $1
#sudo ls -la /root;
for n in {1..5}; do echo "I am executed remotly"; done
hostname -f
#!/bin/bash
SERVERS=$(cat serv.txt)
for host in $SERVERS
do
echo $host
ssh $host 'hostname -f; uptime;'
done
#!/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