#!/bin/bash
while IFS="," read -r f1 f2
do
username="testuser"
SSHPASS='abcde' sshpass -e ssh -t "$username@$f1" "sudo su - root -c 'yum -y install wget'"< /dev/null ;
done < Input.txt
Now i would like to not only get wget installed, but execute a script.
eg: Grep and check if services are running, Remove unwanted folders, etc.
I've tried this:
#!/bin/bash
while IFS="," read -r f1 f2
do
username="testuser"
SSHPASS='abcde' sshpass -e ssh -t "$username@$f1" "sudo su - root -c
if [ -d /opt/xxxx ]; then
rm -rf /opt/xxxx
if [ -d /etc/xxxx ]; then
rm -rf /etc/xxxx
fi"< /dev/null ;
done < Input.txt
It seems not to work. How could I pass a script to execute as root on a remote machine ?