Last active
January 14, 2016 12:56
-
-
Save gottaloveit/320ece95f6ffcc31c0d5 to your computer and use it in GitHub Desktop.
Storing for in case of future need. This runs to pull configs from network Cisco ASA and compares and saves config file to a local network file share location using CIFS and a network file server to store the confgs. It work for the situation it is in, they may not work for every situation, I do not take liability for anything that might go wron…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# written for Cisco ASA 5500 | |
# example usage ./asa_ssh.sh "DEVICE_NAME" DEVICE_IP TFTPD_SERVER_IP "COLO_FACILITY_SHORTNAME" "ASA_OUTBOUND_INTERFACE" | |
# Storing for in case of future need. This runs to pull configs from network Cisco ASA and compares and saves config file | |
# to a local network file share location using CIFS and a network file server to store the confgs. It work for the situation | |
# it is in, they may not work for every situation, I do not take liability for anything that might go wrong, nor do I support | |
# these scripts outside of my own usage. | |
host=$1 | |
ip=$2 | |
myip=$3 | |
colo=$4 | |
interface=$5 | |
now=`date +"%Y_%m_%d"` | |
tftp=/tftpboot | |
compare_dir=$tftp/$host | |
backup_path=/network_device_backups/networking_devices/$colo/firewalls/$host | |
(expect -c " | |
set timeout 5 | |
spawn ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$ip | |
expect \"*rd: \" | |
send \"REDACTED-FOR-SECURITY\r\" | |
expect \"*> \" | |
send \"enable\r\" | |
expect \"Password: \" | |
send \"REDACTED-FOR-SECURITY\r\" | |
expect \"*\# \" | |
send \"copy /noconfirm startup-config tftp://$myip/$host.cfg;int=$interface\r\" | |
expect \"*\# \" | |
send \"exit\r\" | |
exit | |
") | |
mkdir -p $compare_dir | |
mkdir -p $backup_path | |
touch $compare_dir/$host.cfg | |
md5=`md5sum $compare_dir/$host.cfg | awk '{ print $1 }'` | |
echo | |
echo | |
echo "current md5: $md5" | |
newmd5=`md5sum $tftp/$host.cfg | awk '{ print $1 }'` | |
echo | |
echo "new md5: $newmd5" | |
echo | |
if [ $md5 != $newmd5 ] | |
then | |
cp $tftp/$host.cfg $compare_dir/$host.cfg | |
cp $tftp/$host.cfg $backup_path/$host_$now.cfg | |
echo "copied files" | |
fi | |
rm $tftp/$host.cfg | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment