script questions - does not appear to work corretly

Latest response

I have a question regarding a few scripts that appear to connect to all my clients successfully using ssh. Background on this I have a network of 69 clients. I would like to for example tweak the auditd.conf file and push the file across the network. I did create a new template file and was able to transfer to all the clients and when I attempted to copy or move the file to auditd.conf it never performed the action. The template scp copied to each client but did not do the above stated. Here is my script as is.

! /bin/bash

export SSHPASS="";
ssh-keygen && for host in $(cat hosts.txt)
do
sshpass -e ssh-copy-id -o StrictHostKeyChecking=no $host
done;
#
#
for host in $(cat hosts.txt); do ssh "$host" ifconfig | grep -A 30 eth0 | grep -v "lo" | grep -v virbr0 >> /home/user/logrotate/out.$hostoutput.$host;
scp /home/user/logrotate/out.$hostnewaudit.txt ${host}:/etc/audit/;
cd /etc/audit;
cp auditd.conf auditd.conf.back;
cp newaudit.txt auditd.conf;
rm newaudit.txt;
ls -l >> /home/user/logrotate/out.$hostoutput.$host;
systemd-analyze set-log-level notice;
echo $host;
echo "";
echo "";
echo "Audit updated."
cd /home/user/logrotate
done;
exit;

My passsword was not included in the script.
My hosts.txt files contains all the ip's of the clients in the network.
I would also do that same for updating the logrotate.conf files.

Any help would be appreciated as I am a newbie and would like to get my network more contained and streamlined as far as maintenance is concerned.

Thanks Jon

Responses