You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
C# SSH.NET "ERROR: An established connection was aborted by the server" #1028
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 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...
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 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?
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.
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.
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.
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 :(
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.
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?
Activity
jcalla97 commentedon Nov 4, 2022
I'm experiencing the same issue after a FW update. Where you able to figure out a solution?
NeoMorfeo commentedon Nov 4, 2022
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...
jcalla97 commentedon Nov 4, 2022
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()
NeoMorfeo commentedon Nov 4, 2022
can you debug the session and excepcion and check if the server sends you the identificacion?
jcalla97 commentedon Nov 4, 2022
Would that be stored in my SshClient.ConnectionInfo? Or would that be stored in the exception?
NeoMorfeo commentedon Nov 4, 2022
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.
jcalla97 commentedon Nov 4, 2022
I don't see a server identification in my ConnectionInfo. This is my ConnectionInfo for my SshClient after the error gets thrown:
NeoMorfeo commentedon Nov 4, 2022
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?
jcalla97 commentedon Nov 4, 2022
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.
Christin840512 commentedon Nov 7, 2022
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.
jcalla97 commentedon Nov 7, 2022
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.
Christin840512 commentedon Nov 8, 2022
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 :(
jcalla97 commentedon Nov 9, 2022
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.
jcalla97 commentedon Nov 9, 2022
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?
jcalla97 commentedon Nov 10, 2022
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.
johnliaoywl commentedon Nov 15, 2022
I have the same problem. Will SSH.Net support RSA-SHA-256 host key later?
jcalla97 commentedon Nov 15, 2022
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.
Rob-Hague commentedon Oct 19, 2026
fixed in 2023.0.0