Skip to content

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

@Christin840512

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?

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