-
-
Notifications
You must be signed in to change notification settings - Fork 947
Executing different commands using same object throwing Renci.SshNet.Common.SshConnectionException: An established connection was aborted by the server. #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Seems similar to this - https://sshnet.codeplex.com/workitem/563 But it is throwing exception for me |
@vvvarunv I'm not able to reproduce your issue connecting against Ubuntu 14.04.5 LTS using SSH.NET 2016.0.0 and 2016.1.0-beta1. using (var client = new SshClient(server, username, password))
{
client.Connect();
var cmd = client.CreateCommand("hostname");
cmd.Execute();
Console.WriteLine("Command 1: " + cmd.Result);
cmd.Execute("pwd");
Console.WriteLine("Command 2: " + cmd.Result);
client.Disconnect();
} Could you please share your configuration details (I assume you are trying to execute commands on Cisco IOS device) or preferably you might want to use ShellStream to execute several different commands. |
I believe he is running the command against a Cisco device, it is a known problem with some embedded devices that they do not support well exec call, if it is a Cisco divice you will have to use a stream, this way a terminal is created and you can execute commands by writing to it and read the output by reading from the stream directly.
… On Apr 27, 2017, at 8:20 AM, kasbst ***@***.***> wrote:
@vvvarunv <https://github.com/vvvarunv> I'm not able to reproduce your issue connecting against Ubuntu 14.04.5 LTS using SSH.NET 2016.0.0 and 2016.1.0-beta1.
using (var client = new SshClient(server, username, password))
{
client.Connect();
var cmd = client.CreateCommand("hostname");
cmd.Execute();
Console.WriteLine("Command 1: " + cmd.Result);
cmd.Execute("pwd");
Console.WriteLine("Command 2: " + cmd.Result);
client.Disconnect();
}
Preferably you might want to use ShellStream to execute several different commands.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#213 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAf0HheWIx5uh6y2ZHveHM30EujLhHvXks5r0IgZgaJpZM4NFTpn>.
|
Yep, just wanted to be sure as it was already mentioned in this issue #52 :) |
@darkoperator : you are correct, i am running this command against a cisco device. I was able to use shellstream and get past this issue. |
this.shellStreamSSH.Write("\u0003"); |
It's done in #1274 |
The 2023.0.1 version has been released to Nuget: https://www.nuget.org/packages/SSH.NET/2023.0.1 |
2023.0.1 did NOT fix this issue for me on a Cisco device. |
@pray4snow2 you should provide more logs and more information about your environment and device. Do you get an exception? Without this, no one will help you unless you prepare a PR with a solution yourself. |
This issue happens when trying to connect to the end device (Cisco IOS) multiple times, and never happens on the first attempt. Output shows: Exception thrown: 'Renci.SshNet.Common.SshConnectionException' in Renci.SshNet.dll and the exception thrown: Renci.SshNet.Common.SshConnectionException End device logging shows nothing important with a good or bad result, no difference: *Feb 7 04:32:28.520: %SEC_LOGIN-5-LOGIN_SUCCESS: Login Success [user: admin] [Source: 192.168.1.100] [localport: 22] at 04:32:28 EST Wed Feb 7 2024 *Feb 7 04:32:28.640: %SSH-5-SSH_COMPLIANCE_VIOLATION_RSA_KEY_SIZE: SSH RSA Key Size compliance violation detected. Kindly note that the usage of keys smaller than 2048 bits will be deprecated in the upcoming releases. Please revise your key configuration accordingly to avoid service impact. |
}
internal void SendMessage(Message message)
{
if (!_socket.CanWrite())
throw new SshConnectionException("Client not connected."); --> Throws exception here
The text was updated successfully, but these errors were encountered: