sshnet / sshnet/SSH.NET

In certain circumstances, SshClient.Disconnect may never return.

Open
#1,552 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

Observed when doing manual SSH-jumping (I.e using SSH.NET to create an SSH shell in a remote device, then using that device to SSH to another device, and then repeating the procedure in order to reach a third device, the error occurs when the jump to reach this third device fails). When attempting to disconnect the SSH session, it seems to get eternally stuck on the WaitOne() call in: https://github.com/sshnet/SSH.NET/blob/ee054f4d314d81e3aaf6d8ef06608146d92f33ff/src/Renci.SshNet/Session.cs#L828

This can be avoided by raising a Task.Run that fires-and-forgets, of course, but it is less than ideal that it seems to get stuck in this way.

This has not been observed outside of situations where the secondary connection fails, and has otherwise worked fine.

Version: SSH.NET 2024.2.0
Runtime: .NET 9.0.100
OS: Windows, Build 10.00.22621

Contributor guide

Open the contributing guide

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 src/Renci.SshNet/Session.cs at the WaitOne() call around line 828, using the nested SSH-jump scenario where the third connection fails as the reproduction case. Trace the disconnect path and determine why it can wait indefinitely; done means SshClient.Disconnect returns after the failed secondary connection without requiring a fire-and-forget Task.Run.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.