Paramiko with PaloAlto

L0 Member

Paramiko with PaloAlto

Hi There,


I am very new to Python scripting and have started to learn through my lab PaloAlto Firewall.

I wrote a basic script to just return me the output of an operational command. This script works on my lab SRX but hangs on the PaloAlto.


The code snippet : (indentation is correct)

root# vi


import paramiko
import time
import inspect


ssh = paramiko.SSHClient()


timeout = 30

endtime = time.time() + timeout

iin = paramiko.sys.stdin
out = paramiko.sys.stdout
err = paramiko.sys.stderr


iin, out, err = ssh.exec_command("show clock")

print out

while not
if time.time() > endtime:


I have included a while loop because without it the script would just hang forever and I have to manually kill the process.

So after the while loop the script times out without providing any output.


Is this not possible with PaloAlto or only way to automate is via API?


Please help.


L2 Linker

Re: Paramiko with PaloAlto

Yes it is possible to log into the Palo Alto using Paramiko, as long as you get all the timing and everything correct.

L2 Linker

Re: Paramiko with PaloAlto

I use this instead of using exec, I believe exec is only able to run one command.


channel = ssh.invoke_shell()
output = channel.recv(10000)
print output
print "connected to device"

channel.send('show interface all\n')
output3 = channel.recv(1000000)

Like what you see?

Show your appreciation!





The Live Community thanks you for your participation!