-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
channels don't work unless a reference to SSHClient is explicitly kept #44
Comments
Thanks for this bug report -- my SFTP session was mysteriously getting closed and I couldn't figure out why! Is this the intended design for paramiko? This is caused by the SSHClient being registered with the ResourceManager to close its transport when it gets collected. This certainly surprised me, but if it's the intended behavior, maybe it should be documented somewhere. |
This design well predates my involvement so I've got no ready answers. If somebody wants to dig into the Git history for clues or suggest either a doc or API addition to help make this less confusing/surprising, I'd consider a merge. |
In some cases, the SSH client is created, the command is executed, the streams are extracted, and the explicit reference to SSHClient is then discarded (since it was e.g. created in a function that only returns the streams). In this case, the SHSClient may be garbage collected, and the connection's state is undefined. This fix adds a reference from Transport to the SSHClient that created it. The streams have a reference to the Channel, which references the Transport. Now that the Transport references the SSHClient, it won't be garbage collected until it is closed. Closes-Bug: paramiko#44 Related-Bug: paramiko#344
In some cases, the SSH client is created, the command is executed, the streams are extracted, and the explicit reference to SSHClient is then discarded (since it was e.g. created in a function that only returns the streams). In this case, the SHSClient may be garbage collected, and the connection's state is undefined. This fix adds a reference from Transport to the SSHClient that created it. The streams have a reference to the Channel, which references the Transport. Now that the Transport references the SSHClient, it won't be garbage collected until it is closed. Closes-Bug: #44 Related-Bug: #344
In some cases, the SSH client is created, the command is executed, the streams are extracted, and the explicit reference to SSHClient is then discarded (since it was e.g. created in a function that only returns the streams). In this case, the SHSClient may be garbage collected, and the connection's state is undefined. This fix adds a reference from Transport to the SSHClient that created it. The streams have a reference to the Channel, which references the Transport. Now that the Transport references the SSHClient, it won't be garbage collected until it is closed. Closes-Bug: #44 Related-Bug: #344
In some cases, the SSH client is created, the command is executed, the streams are extracted, and the explicit reference to SSHClient is then discarded (since it was e.g. created in a function that only returns the streams). In this case, the SHSClient may be garbage collected, and the connection's state is undefined. This fix adds a reference from Transport to the SSHClient that created it. The streams have a reference to the Channel, which references the Transport. Now that the Transport references the SSHClient, it won't be garbage collected until it is closed. Closes-Bug: paramiko#44 Related-Bug: paramiko#344
In some cases, the SSH client is created, the command is executed, the streams are extracted, and the explicit reference to SSHClient is then discarded (since it was e.g. created in a function that only returns the streams). In this case, the SHSClient may be garbage collected, and the connection's state is undefined. This fix adds a reference from Transport to the SSHClient that created it. The streams have a reference to the Channel, which references the Transport. Now that the Transport references the SSHClient, it won't be garbage collected until it is closed. Closes-Bug: paramiko#44 Related-Bug: paramiko#344
transport: do not prefer kex group16_sha512 and group14_sha256
Using an instance of Channel received from somewhere without a reference to SSHClient being explicitly kept (to prevent it from being garbage collected) sometimes gives unexpected results. For instance, a call to exec_command() raises an exception about the channel being closed, while recv_exit_status() just returns -1.
Here's a synthetic test case.
The text was updated successfully, but these errors were encountered: