sshnet / sshnet/SSH.NET

Renci SSH.net changing remote SFTP port request C#

Offen
#471 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
C#
Sterne
4.4k
Forks
993
Ø Merge
9 T. 21 Std.
Gemergte PRs (30 T.)
1

Beschreibung

I am writing a small piece of code in C# (VS 2017) to upload files to a remote server using SFTP through a SOCKS Proxy.

I have used Renci SSH.net before for other applications similar to this again going through the SOCKS proxy with no issues at all.

However in this application I am having an problem where the Renci SSH.net call to the Socks proxy is for a different Port to the one I requested.

Here is my code
`private static void testSFTPConnection()
{
//get the SFTP Connection Info
ConnectionInfo connInfo = testRemoteSFTP();
try
{
//Start the SFTP Client
using (SftpClient remoteSFTPClient = new SftpClient(connInfo))
{
//Connect the remote session
remoteSFTPClient.Connect();

            //log a successful connection
           Console.WriteLine("SFTP File Upload - connection to the file destination server successful");

            //Disconnect the Destination SFTP connection
            remoteSFTPClient.Disconnect();
        }
    }
    catch(Exception ex)
    {
        Console.WriteLine("SFTP File Upload Exception: " + ex.Message);
    }
}

public static ConnectionInfo testRemoteSFTP()
{
return new ConnectionInfo(remoteHost,50101, remoteUser,ProxyTypes.Socks5, proxyURL,proxyPort, proxyUser, proxyPwd, new PasswordAuthenticationMethod(remoteUser,remotePwd));

}

`
As you can see I am setting the Connection info to call the remote host on port 50101 (as per their request) However when I run the code the SOCKS Proxy tells me I am requesting a connection to the remote server on Port 50297.

When I tried to debug the connection information in VS 2017, the connection object shows me the Port request as being 50101 but it still hits the proxy requesting port 50297

I used WinSCP to test the connection to the remote server through the SOCKS proxy on the port 50101 and it connected through fine.

I used wire shark to try and trap my outgoing connection request and there I can see the Port request has changed to 50297

I am now out of ideas as to what the cause of this could be or what fix to apply so any help in this regard would be appreciated

Thanks in advance

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie damit, das bereitgestellte ConnectionInfo- und SftpClient-Beispiel mit dem SOCKS5-Proxy zu reproduzieren und den Remote-Port 50101 anzufordern. Vergleichen Sie die Proxy-Anfrage in Wireshark mit der WinSCP-Verbindung und ermitteln Sie anschließend, warum SSH.NET den Port 50297 sendet; abgeschlossen, wenn die Ursache und eine verifizierte Behebung oder Einschränkung festgestellt wurden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp
Bereich
networking
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
20/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.