sshnet / sshnet/SSH.NET

DB Connection over SSH not working

Open
#224 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

Hello,
I can’t find out the correct syntax for port-forwarding. With PuTTY it works fine,

  Process.Start("C:\Program Files\PuTTY\plink.exe", "-ssh <user>@<hostname> -pw <password> -P 22 -N -L <localport>:127.0.0.1:<destinationport>")

But if connected with this

  Dim sshClient As New Renci.SshNet.SshClient(<hostname>, 22, <user>, <password>)
  sshClient.Connect()

  Dim port As Renci.SshNet.ForwardedPortLocal = New Renci.SshNet.ForwardedPortLocal("127.0.0.1", <localport>, <hostname>, <destinationport>))
  sshClient.AddForwardedPort(port)
  port.Start()

I’m getting a „Reading from the stream has failed.“-Error when opening the database connection afterwards. The sshClient.isConnected = True and port.isStarted = True. What is the correct way?

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 with the SshClient and ForwardedPortLocal usage shown in the issue, including the host, port, and port.Start() calls. Reproduce the reported database connection failure after the SSH client and forwarded port report connected and started. Done means identifying the correct forwarding setup or documenting the missing usage detail needed to avoid the stream error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.