cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
502
Views
0
Helpful
2
Comments
dhr.tech1
Spotlight
Spotlight

Hi All,

Tried and tested to run pre and post checks for Cisco FTD over Linux Jump servers.

Note: you would require 'ftd_prechecks.txt' with the CLI commands saved in the same folder as your code.

##############################################

from netmiko import ConnectHandler
from getpass import getpass
import time
import re

user_name = input("Please enter your username for Jump Server: ")
pass_word = getpass("Please enter your password for Jump Server: ")


jump = {
"device_type": "linux",
"host": "172.##",
"username": user_name,
"password": pass_word,
"timeout": 60,
"session_log": "netmiko_jump.log", # debug transcript
}

# At this point, you should be on the FTD shell/CLI.

output_file = open('ftd_pcheck_output.txt', 'a')
# Use timing-based command if prompt detection is uncertain:
with open('ftd_prechecks.txt') as file:
verif_commands = file.read().splitlines()
for command in verif_commands:
cmd_output = ssh.send_command_timing(command, strip_prompt=False, strip_command=False)
print(f"Output of '{command}':\n{cmd_output}\n")
output_file.write("\nThe below information is fetched from " + FTD_IP)
output_file.write("\n" + cmd_output + "\n")
output_file.close()

 

# When finished:
ssh.disconnect()

2 Comments
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: