pip install -r requirements.txt # Complete backup (configurations + crypto + file listing) python asa_downloader.py --host 192.168.1.1 --username admin --password secret --backup-all Download only running configuration python asa_downloader.py --host 192.168.1.1 --username admin --password secret --running-config Download specific file from flash python asa_downloader.py --host 192.168.1.1 --username admin --password secret --download-file /asdm-771.bin List files in flash memory python asa_downloader.py --host 192.168.1.1 --username admin --password secret --list-flash Download ASDM image python asa_downloader.py --host 192.168.1.1 --username admin --password secret --download-asdm Alternative: Using SCP Directly (No Python) # Enable SCP on ASA first: # ssh scopy enable # username admin password secret # aaa authentication ssh console LOCAL Download running config via SCP scp admin@192.168.1.1:running-config ./running-config-backup.cfg Download ASDM image scp admin@192.168.1.1:/asdm-771.bin ./ Download startup config scp admin@192.168.1.1:startup-config ./startup-config-backup.cfg ASA Pre-Configuration Required ! Enable SSH and SCP on ASA crypto key generate rsa modulus 2048 ssh 0.0.0.0 0.0.0.0 outside ssh scopy enable username admin password YourPassword aaa authentication ssh console LOCAL username admin attributes privilege-level 15 ! Enable HTTP/HTTPS for ASDM (if needed) http server enable http 192.168.0.0 255.255.255.0 inside
def download_startup_config(self, destination_path): """Download startup configuration""" self.logger.info("Downloading startup configuration...") config = self.execute_command("show startup-config") if config: filename = os.path.join(destination_path, f"startup_config_{self.hostname}.cfg") with open(filename, 'w') as f: f.write(config) self.logger.info(f"Startup config saved to: {filename}") return filename return None cisco asa 5506-x download
def list_flash_files(self): """List files in flash memory""" self.logger.info("Listing flash files...") output = self.execute_command("show flash:") if output: print("\nFlash Files:") print("=" * 60) print(output) return output return None pip install -r requirements
finally: downloader.disconnect() if == " main ": main() Installation Requirements # Install required Python packages pip install paramiko scp Or create requirements.txt cat > requirements.txt << EOF paramiko>=2.8.0 scp>=0.13.3 EOF f"startup_config_{self.hostname}.cfg") with open(filename
try: if not downloader.connect(): sys.exit(1) # Execute requested actions if args.backup_all: backup_dir = downloader.backup_asa(args.output) print(f"\n✓ Backup completed successfully!") print(f" Location: {backup_dir}") elif args.running_config: filepath = downloader.download_running_config(args.output) if filepath: print(f"✓ Running config downloaded: {filepath}") elif args.startup_config: filepath = downloader.download_startup_config(args.output) if filepath: print(f"✓ Startup config downloaded: {filepath}") elif args.list_flash: downloader.list_flash_files() elif args.download_asdm: success = downloader.download_asdm_image(args.output) if success: print("✓ ASDM image downloaded successfully") else: print("✗ Failed to download ASDM image") elif args.download_file: local_filename = os.path.basename(args.download_file) local_path = os.path.join(args.output, local_filename) success = downloader.download_file_via_scp(args.download_file, local_path) if success: print(f"✓ File downloaded: {local_path}") else: print("✗ File download failed") else: # Default: download running config if no action specified downloader.download_running_config(args.output)
def disconnect(self): """Close SSH connection""" if self.ssh_client: self.ssh_client.close() self.logger.info("SSH connection closed") def main(): parser = argparse.ArgumentParser(description='Cisco ASA 5506-X Download Utility') parser.add_argument('--host', required=True, help='ASA hostname or IP address') parser.add_argument('--username', required=True, help='SSH username') parser.add_argument('--password', required=True, help='SSH password') parser.add_argument('--port', type=int, default=22, help='SSH port (default: 22)') parser.add_argument('--output', default='./asa_backups', help='Output directory')