paramiko / paramiko/paramiko

[BUG] - SSHTunnelForwarder (using paramiko as a proxy) leaves defunct SSH zombie processes

Open
#2,470 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
Python
Stars
9.9k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

Are you using paramiko as a client or server?

Client

What feature(s) aren't working right?

Something else

What version(s) of paramiko are you using?

3.5.0

What version(s) of Python are you using?

3.9.6

What operating system and version are you using?

Linux, MacOS

If you're connecting as a client, which SSH server are you connecting to?

AWS instance from my desktop

If you're using paramiko as part of another tool, which tool/version?

sshtunnel==0.4.0

Expected/desired behavior

Paramiko would not leave a zombie SSH process

Actual behavior

Simple application that opens a forwarder to a remote system, makes a PostgreSQL query and then stops the forwarder.
If I add a sleep after the forwarder.stop() I see a defunct SSH process which goes away when the Python app exits.
Problem: If this scenario is used with a long running Python process, it keeps leaving more and more defunct processes.
I believe I've tracked this down to paramiko's proxy.py. Its killing SSH but not waiting for it and leave zombies.

Please advise.

How to reproduce

Create simple proxy tunnel and after close().... sleep for a bit, you will see a (zombie) SSH process.

Anything else?

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Paramiko's proxy.py and trace the process lifecycle used when an SSHTunnelForwarder is stopped or closed. Reproduce the tunnel scenario with a PostgreSQL query, then wait after shutdown and inspect for a defunct SSH process. Done means repeated tunnel shutdowns no longer accumulate zombie processes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.