sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
4k stars 931 forks source link

Exception "Session operation has timed out" upon connect to some hosts #722

Open mrgadget opened 4 years ago

mrgadget commented 4 years ago

I'm having a really odd occurrence and I've troubleshooted back to this library - or a combination of factors, including this library.

SSH.NET is working great to hundreds of devices behind multiple firewalls - but! I have a handful of devices behind a specific firewall that I'm trying to establish SSH sessions to. I can fire up putty and SSH to any one of them fine (all defaults, from the same source host), yet when I attempt to connect with SSH.NET I get the following exception (on the .Connect() line);

Error Message Session operation has timed out

Stack Trace

   at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)
   at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle)
   at Renci.SshNet.Session.Connect()
   at Renci.SshNet.BaseClient.Connect()
   at test.Ssh.Client.Connect() in C:\Users\dev\source\test\Ssh.vb:line 59

Increasing the timeout makes no difference, besides, Putty connects instantly. User/pass makes no diff if right or wrong, error is the same.

Is there any way to get any debug logging out of SSH.NET?

Any other ideas?

Basic Code to Re-Produce

Imports Renci.SshNet
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim cl As New SshClient("172.16.0.2", "test.user", "test.pass")
        Try
            cl.Connect()
        Catch ex As Exception
            Debug.WriteLine(ex.Message)
        End Try
    End Sub
End Class

This code will probably work fine when you test it - because it does for nearly all my hosts too - just these select few!

mrgadget commented 4 years ago

Have replicated this with library built from current commit in this repo.