- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
03-18-2020 06:38 AM
I have a very simple python script that uses ssh=paramiko.SSHClient(), ssh.connect (host, 22, user, password), stdin, stdout, stderr=ssh.exec_command(command), and for line in stdout.read().splitlines(): print(line).
When I set host, user, password and command, e.g. "show ip int brief", to connect to a Cisco router, everything works fine and the script prints out the results that I expect. However, when I set them to connect to a PAN firewall, e.g. command="show clock", my script connects to the FW, which I confirm by looking in the FW's system log, but all I get returned is the 'Number of failed attempts since last successful login: 0' message?
Any ideas - I'm sure I'm just missing something basic. Do I need to import any of the PAN packages or can I just run run simple CLI commands using paramiko?
PS: I sleep for 20 seconds after connecting before running the ssh.exec_command()
Thanks,
Ian
03-18-2020 03:06 PM
Solved by:
import pandevice
my_fw = firewall.Firewall(host, user, password)
response = my_fw.op(command2, xml=True)
print(response)
The response is a page of XML, so needs to be interpreted, but I do get the answers I want 🙂
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!