You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IE, repeating this will eventually end up with paramiko.ssh_exception.ChannelException: (1, 'Administratively prohibited') as the server rejects additional SSH connections.
Looking at debug log, the number of channels stays constant while number of active SSH connections grows
<paramiko.Transport at 0x151d4320 (cipher aes128-ctr, 128 bits) (active; 2 open channel(s))>]
My workaround has been to manually kill the command in addition to channel close chan.exec_command('killall long_running_command')
I used paramiko to ssh from a linux device to a Windows device, and ran a long running command. After calling the channel.close, the chanel was still alive. I checked that the channel object exists in ssh_client.get_transport()._channels._map and the pid of the shell was still alive on Windows device.
Also it is interesting to note that after calling channel.close, the ssh connection is alive, the shell process is alive, and the long running process is killed.
I don't think Channel class should do job-control, because paramiko intents that direct use of paramiko itself is only intended for users who need advanced/low-level primitives.
Instead, we could send a signal to terminate the command using signals feature (needed apply #1535):
withtransport.open_session() aschannel:
channel.exec_command('sleep 86400') # long running commandtry:
# Waiting for termination of the command...finally:
channel.send_signal('TERM')
Activity
mhaoli commentedon Jul 19, 2022
I'm also facing this problem.
I used paramiko to ssh from a linux device to a Windows device, and ran a long running command. After calling the
channel.close, the chanel was still alive. I checked that the channel object exists inssh_client.get_transport()._channels._mapand the pid of the shell was still alive on Windows device.Also it is interesting to note that after calling
channel.close, the ssh connection is alive, the shell process is alive, and the long running process is killed.My paramiko version: 2.7.1
azertyfun commentedon Jun 21, 2023
Just ran into this issue, but in my case it's because I had the following workaround for an unrelated issue:
Turns out I had to close that connection even if it had failed:
jun66j5 commentedon Jun 21, 2023
I don't think
Channelclass should do job-control, because paramiko intents that direct use of paramiko itself is only intended for users who need advanced/low-level primitives.Instead, we could send a signal to terminate the command using
signalsfeature (needed apply #1535):