I am trying to close or open one of the port on Cisco Router 2811. When using putty, here are the commands

After SSH login

config t int f0/0/0 no shutdown

I was able to login router using Rebex SSH lib. I then

    respString = ssh.RunCommand("config t\r\n");                
            textBox1.Text += respString;

Which returns correct response. The router is now in config mode. the command prompt looks like this now: router1(config)#

I then send respString = ssh.RunCommand("int f0/0/0\r\n"); Which cause the following exception:

Rebex.Net.SshException: Error while sending packet. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at Rebex.Net.ProxySocket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at Rebex.Net.SshSession.clmbOg(BBdsJfZ , Boolean ) --- End of inner exception stack trace --- at Rebex.Net.SshSession.clmbOg(BBdsJfZ , Boolean ) at Rebex.Net.SshSession.clmbOg(BBdsJfZ ) at Rebex.Net.SshSession.BGzjKi(SshChannelType , Int32 , Object[] ) at Rebex.Net.SshSession.OpenSession() at Rebex.Net.Ssh.StartCommand(String command) at TestSSH.Form1.btnConnect_Click(Object sender, EventArgs e) in

asked 29 Mar '10, 22:15

John's gravatar image

John
161
accept rate: 0%


To determine the cause of the exception we need a communication log. How it can be produced is described here. Can you send it to support@rebex.net please?

Some comments to your code:

1) the RunCommand method runs one separate command (in newly created ssh-subchannel) and exits. It means the command runs in new clear envirnoment, so it is unaffected by any changes made by previous calls of the RunCommand, StartCommand or StartShell methods. So using the RunCommand method in this case cannot work. You need to use the StartShell method.

2) there is no need to specify \r\n in the RunCommand method. Some servers may have problems with it

link

answered 30 Mar '10, 10:50

Lukas%20Matyska's gravatar image

Lukas Matyska ♦♦
78217
accept rate: 27%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×39
×1

Asked: 29 Mar '10, 22:15

Seen: 1,271 times

Last updated: 30 Mar '11, 02:22