-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
When there are no longer any references the the gateway ssh session but there are to the remote session, the gateway session gets garbage collected too early, resulting in remote sessions failing with the following error:
paramiko.ssh_exception.SSHException: SSH session not active
Here's some code to re-create the issue:
import os
from jumpssh import SSHSession
def get_remote_session():
user = os.getlogin()
gateway_session = SSHSession(
host="127.0.0.1",
username=user,
).open()
remote_session = gateway_session.get_remote_session(
host="127.0.0.2",
username=user,
)
return remote_session # gateway ssh gets garbage collected here, which closes the gateway transport still needed by the remote session
if __name__ == "__main__":
with get_remote_session() as remote_session:
remote_session.get_sftp_client().get(
".bashrc",
f"{os.path.expanduser('~')}\\Documents\\bashrc.txt"
)Which results in:
paramiko.ssh_exception.SSHException: SSH session not active
One possible fix which I've tested as working would be to add a reference to the gateway SSH session inside the jumpssh.SSHSession class. What do you think?
Metadata
Metadata
Assignees
Labels
No labels