Skip to content

C# SSH.NET "ERROR: An established connection was aborted by the server" #1028

Closed

Description

@Christin840512

I'm trying to connect to a server thru SSH.NET. It worked fine before but started to show "An established connection was aborted by the server" after some FW update on the server. Below is the code I'm using

private void HandleKeyEvent(object sender, AuthenticationPromptEventArgs e)
        {
            foreach (AuthenticationPrompt prompt in e.Prompts)
            {
                if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1)
                {
                    prompt.Response = "password";
                }
            }
        }
private void sshConnectBut_Click(object sender, EventArgs e)
        {
            var auth1 = new PasswordAuthenticationMethod("username", "password");
            var auth2 = new KeyboardInteractiveAuthenticationMethod("username");
            auth2.AuthenticationPrompt += new EventHandler<AuthenticationPromptEventArgs>(HandleKeyEvent);
            ConnectionInfo conInfo = new ConnectionInfo("Host", 22, "username", auth1, auth2);                
            
            this.sshClient = new SshClient(conInfo);
            this.sshClient.ConnectionInfo.Timeout = TimeSpan.FromSeconds(120);
            
            this.sshClient.Connect();   **<---- Error happened here**
        }

Can anyone help me on this issue please?

Activity

  1. jcalla97 commented on Nov 4, 2022

    @jcalla97

    I'm experiencing the same issue after a FW update. Where you able to figure out a solution?

  2. NeoMorfeo commented on Nov 4, 2022

    @NeoMorfeo

    Can you check the máx connections limits in the server? in my case, this was reached after 3 attemps, and the server close the connection before establishing it, or setting the server identification...

  3. jcalla97 commented on Nov 4, 2022

    @jcalla97

    I'm the only one trying to connect to the device. So there are 0 connections when I'm trying to connect. Here is where the error gets thrown:
    Renci.SshNet.Common.SshConnectionException: An established connection was aborted by the server.
    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.CreateAndConnectSession()
    at Renci.SshNet.BaseClient.Connect()

  4. NeoMorfeo commented on Nov 4, 2022

    @NeoMorfeo

    can you debug the session and excepcion and check if the server sends you the identificacion?

  5. jcalla97 commented on Nov 4, 2022

    @jcalla97

    Would that be stored in my SshClient.ConnectionInfo? Or would that be stored in the exception?

  6. NeoMorfeo commented on Nov 4, 2022

    @NeoMorfeo

    Yes, in the SshClient.ConnectionInfo.

    The problem I had face is that connection info is not send by the server, so it cannot be opened.

  7. jcalla97 commented on Nov 4, 2022

    @jcalla97

    I don't see a server identification in my ConnectionInfo. This is my ConnectionInfo for my SshClient after the error gets thrown:

    image

  8. NeoMorfeo commented on Nov 4, 2022

    @NeoMorfeo

    I was asking for the "server Version" which is shared in the connection phase... so you are not facing the same thing... sorry :(
    if you connect using ssh cli using -vvv is there any problem?

  9. jcalla97 commented on Nov 4, 2022

    @jcalla97

    No I'm able to connect via ssh on cli and through putty with no issue. I only get the problem when trying to use the library. The cli doesn't have any issues when running with -vvv.

  10. Christin840512 commented on Nov 7, 2022

    @Christin840512
    Author

    I'm the only one trying to connect to the device. So there are 0 connections when I'm trying to connect. Here is where the error gets thrown: Renci.SshNet.Common.SshConnectionException: An established connection was aborted by the server. 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.CreateAndConnectSession() at Renci.SshNet.BaseClient.Connect()

    I got exactly same error massage as you and still not able to figure it out :(
    I have checked all security settings of both two version of FW and there is no difference between them.

  11. jcalla97 commented on Nov 7, 2022

    @jcalla97

    So I guess my FW update changed the host key algorithm they use. They originally used rsa-sha2-512/rsa-sha2-256 and updated to use ssh-rsa. But that shouldn't be an issue as to why the connection is getting aborted because this library supports ssh-rsa keys.

  12. Christin840512 commented on Nov 8, 2022

    @Christin840512
    Author

    Mine is even weird, the host key algorithm keeps the same in the new FW but just can't connect it... Really hope that someone can help on this issue :(

  13. jcalla97 commented on Nov 9, 2022

    @jcalla97

    Have you had any updates in the last 2 days? I've been trying to create a new key to test with, but I'm not able to on my server. If you could test this with a new key pair, let me know what the result is.

  14. jcalla97 commented on Nov 9, 2022

    @jcalla97

    After doing some more digging, I found that my server updated to OpenSSH version 9.0p1. Can you let me know if you are using the same version of OpenSSH if you are using that for your server?

  15. jcalla97 commented on Nov 10, 2022

    @jcalla97

    I have come to the conclusion that my server uses rsa-sha2-256 and rsa-sha512 host key algorithms which is not supported by SSH.Net.

  16. johnliaoywl commented on Nov 15, 2022

    @johnliaoywl

    I have the same problem. Will SSH.Net support RSA-SHA-256 host key later?

  17. jcalla97 commented on Nov 15, 2022

    @jcalla97

    There's this pull request #971 that is a work in progress it looks like, but it hasn't been touched since September so i'm not sure.

  18. Rob-Hague commented on Oct 19, 2026

    @Rob-Hague
    Collaborator

    fixed in 2023.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions