Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"paramiko.ChannelException: Administratively prohibited" encountered midway through a script

I'm using Python to SSH into a host, run bash commands, and then parse results in a Pythonic way into several data structures for later display.

I'm using the Paramiko library for SSH and executing commands on the remote host like so:

ssh = paramiko.SSHClient()
ssh.exec_command("command goes here")

I'm running many commands this way and it seems most of them are working (I'm looping through a file and constructing file paths on the remote server to run the commands on). However, about halfway through execution I'm hitting this error.

I think it has something to do with the volume of ssh.exec_command() calls I'm making but I'm not sure. Any ideas?

like image 635
riggspc Avatar asked Dec 07 '22 07:12

riggspc


1 Answers

I believe I've solved it: because exec_command() is non-blocking I was essentially trying to run a ton of commands all at once on the remote machine. This was against policy and was blocked.

I worked around this by forcing my script to wait until each command was executed via stdout.readlines(). It's working great now.

like image 124
riggspc Avatar answered Dec 08 '22 20:12

riggspc