sshnet / sshnet/SSH.NET

Remote port forwarding

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

I have a linux VM on azure cloud and a remote system.
I am trying to get port forwarding to work. So far I have the folloowing.

private void createConn()
{
try
{
if (!client.IsConnected)
{
client.Connect();
Console.WriteLine("Successful!!!!");
client.SendKeepAlive();
var port = new ForwardedPortRemote("127.0.0.1", 22, "127.0.0.1", 22222);

                client.AddForwardedPort(port);
                Console.WriteLine("port.Start");
                port.Start();
                Console.WriteLine("Hold port open..");
               port.Stop();
                Console.WriteLine("port closed");
                client.Disconnect();

            }
        }
        catch (Exception e)
        {
            ErrorLog.Error("Connection Failed!!!", e.Message);
        }
    }

The code runs fine but my connection gets refused when I try to run "ssh user@localhost -p 22222" in my azure VM. Do you have any idea what I am missing here?

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 at createConn and the ForwardedPortRemote entry point, then reproduce the reported connection-refused result from the Azure VM using the shown arguments. Check the port and client lifecycle around port.Start(), port.Stop(), and client.Disconnect(); done means the expected remote forwarding behavior is documented or reproduced with a confirmed fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
cloud, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.