[paramiko] SSHClient.exec_command , ChannelException: Administratively prohibited 2
thk
thk at kaotonik.net
Thu Dec 20 12:01:28 PST 2007
James Bardin wrote:
> thk wrote:
>> Hello.
>> I am using paramiko.SSHClient in a python application I am building.
>> I am issuing "cd" commands but it seems that SSHClient does not keep
>> the session open so if I "cd" to another directory and issue "pwd"
>> after , I am again in my home directory .
>> I mean every command is like connecting again and being in the ~
>> directory.
>> if I issue a command like " cd dir; pwd" then I see from the output
>> of pwd that it has changed directory to dir.
>> But not if I do :
>> SSHClient.exec_command("cd dir")
>> SSHClient.exec_command("pwd").
>>
> exec_command opens a new channel for each command. From
> channel.exec_command:
> " When the command finishes executing, the channel will be closed and
> can't be reused. You must open a new channel if you wish to
> execute
> another command."
>
> You probably want to look at SSHClient.invoke_shell(self,
> term='vt100', width=80, height=24) for an interactive shell.
>
>> Also:
>> In another situation I am connecting with sshclient and then I issue
>> commands
>> on the remote host, at every 5000 milliseconds interval.
>>
>> After the 10th or so time ,
>> paramiko sshclient raises an exception:
>>
>> / File "/usr/lib/python2.5/site-packages/paramiko/client.py", line
>> 314, in exec_command
>> chan = self._transport.open_session()
>> File "/usr/lib/python2.5/site-packages/paramiko/transport.py", line
>> 595, in open_session
>> return self.open_channel('session')
>> File "/usr/lib/python2.5/site-packages/paramiko/transport.py", line
>> 696, in open_channel
>> raise e
>> ChannelException: Administratively prohibited
>>
> I think that's the server throttling your number of channels.
But aren't the channels closing?
> You either need to maintain an open channel for subsequent commands,
> or send everything as one command.
>
> Take a look at interactive.py in the demos folder, and invoke_shell()
> in both client.py and channel.py
>
>
> -jim
>
Thanks for the reply.
Basically i am looking for a non blocking way to execute commands on the
server.
I believe if i use interactive_shell I have to implement it with threads
so I can code a non blocking function , because these methods block ?
So one alternative is to do a transport connect and the in each loop
get a new channel with t.open_session()?
More information about the paramiko
mailing list