#!/bin/bash # Sync a file to a remote set of servers using scp and check using diff # NOTE: This requires the use of 'sshpass' and IS insecure in nature # It also assumes the user credentials are identical on all hosts # and that they have the necessary permissions on the remote directory # Author: Nathan Thomas LOGFILE='/var/log/sync_files.log' SSH_USER='non-root-user' SSH_PASS='password' CONF_FILE='/etc/appdir/myconfig.conf' SERVERS=('server1.fqdn.com' 'server2.fqdn.com' 'server3.fqdn.com') for HOST in "${SERVERS[@]}" ; do # NOTE: This won't work if the host keys are not already in the ssh cache # Flush ssh hosts - Either uncomment these two lines on first run or you could leave it uncommented for hosts that change addresses a lot Continue reading "Bash Script – Sync a File to an Array of Hosts"