sshnet / sshnet/SSH.NET

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

Open
#1,028 17 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'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?

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

The report names no repository file or test; start by reviewing the ConnectionInfo setup and the failure at sshClient.Connect(). Use the comment thread to establish whether the firewall change, authentication methods, or server-side disconnect is reproducible, then document a confirmed cause and a regression test or minimal reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.