Thanks Iguinn, tweaked this a bit for non-root user account... and this works!
#!/bin/sh
HOSTS_FILE="/opt/forwarderlist"
WGET_CMD="wget -O splunkforwarder..."
INSTALL_FILE="splunkforwarder-6....tgz"
DEPLOY_SERVER="xx.xx.xx.xx:8089"
PASSWORD="newpassword"
REMOTE_SCRIPT="
cd /opt
sudo $WGET_CMD
sudo tar -xzf $INSTALL_FILE
sudo useradd -m -r splunk
sudo chown -R splunk:splunk /opt/splunkforwarder
### /opt/splunkforwarder/bin/splunk enable boot-start -user splunk
sudo -u splunk /opt/splunkforwarder/bin/splunk start --accept-license --answer-yes --auto-ports --no-prompt
sudo -u splunk /opt/splunkforwarder/bin/splunk set deploy-poll \"$DEPLOY_SERVER\" --accept-license --answer-yes --auto-ports --no-prompt -auth admin:changeme
sudo -u splunk /opt/splunkforwarder/bin/splunk edit user admin -password $PASSWORD -auth admin:changeme
sudo -u splunk /opt/splunkforwarder/bin/splunk restart
"
echo "In 5 seconds, will run the following script on each remote host:"
echo
echo "===================="
echo "$REMOTE_SCRIPT"
echo "===================="
echo
sleep 5
echo "Reading host logins from $HOSTS_FILE"
echo
echo "Starting."
for DST in `cat "$HOSTS_FILE"`; do
if [ -z "$DST" ]; then
continue;
fi
echo "---------------------------"
echo "Installing to $DST"
sudo ssh -t "$DST" "$REMOTE_SCRIPT"
done
echo "---------------------------"
echo "Done"
... View more