pfsense config backup https://www.gremwell.com/ en "Proper" pfSense backup script https://www.gremwell.com/node/397 <span>&quot;Proper&quot; pfSense backup script</span> <div><p>Well, maybe the title is a bit ambitions, but at least the script below is is an improvement comparing to these two approaches: <a href="http://doc.pfsense.org/index.php/Remote_Config_Backup">1</a> and <a href="http://forum.pfsense.org/index.php?action=printpage;topic=20697.0">2</a>:<br /> * It validates server-side certificate instead of ignoring them<br /> * Logs out to invalidate the session cookie and wipes the temporary file used to store it<br /> * Does not fetch whole bulk of RRD data</p> <p><code><br /> #!/bin/sh -e</code></p> <p>user=***<br /> password=***<br /> host=***</p> <p>cacert=$host-cacert.pem<br /> cfgfile=$host-`date +%Y%m%d%H%M%S`.xml</p> <p>cookiejar=`mktemp`</p> <p>## authenticate and save session cookie<br /> wget -q -O /dev/null --keep-session-cookies --save-cookies $cookiejar \<br /> --post-data "login=Login&amp;usernamefld=$user&amp;passwordfld=$password" \<br /> --ca-certificate $cacert https://$host/</p> <p>## download the config<br /> wget -q --load-cookies $cookiejar \<br /> --post-data 'Submit=download&amp;donotbackuprrd=on' -O $cfgfile \<br /> --ca-certificate $cacert https://$host/diag_backup.php</p> <p>## logout to invalidate session cookie<br /> wget -q -O /dev/null --load-cookies $cookiejar \<br /> --ca-certificate $cacert https://$host/index.php?logout</p> <p>## erase session cookie<br /> rm $cookiejar<br /></p> <p>To use it:<br /> 1. Make your firewall use non-default certificate. It is easy to generate a certificate in pfSense with its built-in CA. Make sure CN of the new certificate matches IP/hostname you will use to access the firewall.<br /> 2. Make CA certificate in PEM format available to this script ($host-cacert.pem file).<br /> 2. Optional: create lower-privileged user for backup retrieval, it only needs access to "Diag/Backup-Restore" page.<br /> 3. Set user/password/host parameters.</p> <p>The script might be improved by adding config encryption. Should be useful because the configs apparenly carry unsalted MD5 password hashes.</p> </div> <span><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">abb</span></span> <span>Sat, 10/29/2011 - 22:01</span> Sat, 29 Oct 2011 20:01:31 +0000 abb 397 at https://www.gremwell.com