SSH towards Cisco (General questions)
by dirk, Thursday, March 17, 2011, 16:47 (4998 days ago)
I'm using the wodSSH component using VB6.
If we want to verify diskspace on a remote linux system, then we connect and send
df ;exit
that way the DF is executed and the connection to the Linux system is stopped , we can then via the properties of the component see what we get back from the DF command and act accordingly.
Now we want to do something similar towards a Cisco router (we want to ping via the router). However doing
ping ip 1.2.3.4;exit
isn't working (at least not on my router).
Do you have any advice how I can detect that I received all the output from the router (remote system) and then disconnect (logout/logoff/exit)?
dirk
Re: SSH towards Cisco
by wodDamir, Thursday, March 17, 2011, 17:06 (4998 days ago) @ dirk
Hi Dirk,
You say it doesn't work. What exactly happens?
Do you receive anything?
How do you execute this? Can you please be more specific?
Regards,
Damba
Re: SSH towards Cisco
by dirk, Thursday, March 17, 2011, 18:21 (4998 days ago) @ wodDamir
Hi Dirk,
You say it doesn't work. What exactly happens?
Do you receive anything?
How do you execute this? Can you please be more specific?
Regards,
Damba
Well the IOS itself doesn't accept that syntax (separate the commands by ;) so I need a way from within the component to detect that all is done.
Currently I do
ssh.login =
ssh.password=
ssh.command=
ssh.connect
and via the ssh_received event I get the data back.
However as I currently don't know that it's the end I keep waiting until <timeout> and don't know after that timeout IF I got all or if I only got part of the normal output.
Re: SSH towards Cisco
by wodDamir, Thursday, March 17, 2011, 18:27 (4998 days ago) @ dirk
Dirk,
This is related to SSH or Telnet protocols?
When Command property is used in SSH, the component will only disconnect once the command is executed.
However, why don't you connect, and execute commands using Send or Execute/WaitFor methods?
Regards,
Damba
Re: SSH towards Cisco
by dirk, Thursday, March 17, 2011, 18:43 (4998 days ago) @ wodDamir
Dirk,
This is related to SSH or Telnet protocols?
When Command property is used in SSH, the component will only disconnect once the command is executed.
However, why don't you connect, and execute commands using Send or Execute/WaitFor methods?
Regards,
Damba
It's the SSH protocol.
Not sure about the send/execute/waitfor options.
I suppose that I should then wait for the prompt, send the command and wait again for the prompt?
Re: SSH towards Cisco
by wodDamir, Thursday, March 17, 2011, 18:49 (4998 days ago) @ dirk
Dirk,
In case of SSH, there's no need to even use exit part. When Command property is used, the component connects, executes the specified command and disconnects once it receives command output. This mechanism is implemented in SSH by default.
You can also use ExitStatus to check if there was an error in command execution. You can find more info on ExitStatus here: http://www.weonlydo.com/SSH/Help/wodSSH-ExitStatus.html
As for Send or Execute/WaitFor, you're right. You would need to wait for prompt execute a command and get it's response.
Hope this helps.
Regards,
Damba
Re: SSH towards Cisco
by dirk, Thursday, March 17, 2011, 18:53 (4998 days ago) @ wodDamir
Dirk,
In case of SSH, there's no need to even use exit part. When Command property is used, the component connects, executes the specified command and disconnects once it receives command output. This mechanism is implemented in SSH by default.
You can also use ExitStatus to check if there was an error in command execution. You can find more info on ExitStatus here: http://www.weonlydo.com/SSH/Help/wodSSH-ExitStatus.html
As for Send or Execute/WaitFor, you're right. You would need to wait for prompt execute a command and get it's response.
Hope this helps.
Regards,
Damba
Well that's not how I see it working.
I'm using teh .COMMAND property but the component is not disconnecting at all from the remote Cisco.
Do you want me to use one of the examples and then send you some output to show this? (if so what output and what example to use)?
Re: SSH towards Cisco
by wodDamir, Thursday, March 17, 2011, 20:36 (4998 days ago) @ dirk
Dirk,
I see. It seems that the component doesn't disconnect automatically. Let me check it out.
I'll let you know as soon as I have news on this.
Regards,
Damba
Re: SSH towards Cisco
by wodDamir, Thursday, March 17, 2011, 20:57 (4998 days ago) @ wodDamir
Dirk,
Actually, it does. Everything works ok on my side. Does component disconnect from on non-cisco devices if you don't set exit in command?
Is there any chance we could perhaps connect to that device and reproduce the problem?
Regards,
Damba
Re: SSH towards Cisco
by dirk, Thursday, March 17, 2011, 21:20 (4998 days ago) @ wodDamir
Dirk,
Actually, it does. Everything works ok on my side. Does component disconnect from on non-cisco devices if you don't set exit in command?
Is there any chance we could perhaps connect to that device and reproduce the problem?
Regards,
Damba
With one of the samples (slighly modified so it uses the .COMMAND too) it does indeed work towards a Linux system. Towards the Cisco it's still not working. One of the differnces mights be that the Cisco only has SSH1, while the Linux only has SSH2.
(with my code even towards the Linux system it seems not to auto-disconnect).
Connecting the Cisco to the internet is not possible. I can give you loggings (from the component if that's possible) or a network trace.
Re: SSH towards Cisco
by wodDamir, Thursday, March 17, 2011, 22:46 (4998 days ago) @ dirk
Dirk,
I don't have a cisco router to test against. However, is it possible that the ping on that device doesn't have a limit of tries?
I.e. ping some_host on linux will cause it to ping indefinitely unless specified as ping some_host -c count_number . The later one would only ping as many times as count_number is set.
Can you try a similiar thing?
I tried the same on SSH1 server, and it works like a charm.
Regards,
Damba
Re: SSH towards Cisco
by dirk, Friday, March 18, 2011, 07:05 (4998 days ago) @ wodDamir
Dirk,
I don't have a cisco router to test against. However, is it possible that the ping on that device doesn't have a limit of tries?
I.e. ping some_host on linux will cause it to ping indefinitely unless specified as ping some_host -c count_number . The later one would only ping as many times as count_number is set.
Can you try a similiar thing?
I tried the same on SSH1 server, and it works like a charm.
Regards,
Damba
ping ip 1.2.3.4
will cause the Cisco to send 5 frames that's all
See example:
[code]csc4500#ping ip 172.22.150.33
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.22.150.33, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
csc4500#[/code]
Re: SSH towards Cisco
by dirk, Friday, March 18, 2011, 08:53 (4998 days ago) @ dirk
Dirk,
I don't have a cisco router to test against. However, is it possible that the ping on that device doesn't have a limit of tries?
I.e. ping some_host on linux will cause it to ping indefinitely unless specified as ping some_host -c count_number . The later one would only ping as many times as count_number is set.
Can you try a similiar thing?
I tried the same on SSH1 server, and it works like a charm.
Regards,
Damba
Just tried it with a different command (send to the router) and the result is the same, no disconnect is done after the execution of the command.
Re: SSH towards Cisco
by wodDamir, Friday, March 18, 2011, 10:41 (4997 days ago) @ dirk
Dirk,
Can you please show me a snippet of the code before Connect method?
Regards,
Damba
Re: SSH towards Cisco
by dirk, Friday, March 18, 2011, 10:47 (4997 days ago) @ wodDamir
Dirk,
Can you please show me a snippet of the code before Connect method?
Regards,
Damba
Ssh.LicenseKey = my-license-key
Ssh.DebugFile = c:ssh.log
Ssh.HostName = Text1
Ssh.Port = Text2
Ssh.Login = Text3
Ssh.Password = Text4
Ssh.Command = Text5
Ssh.Connect
(also tried adding a vbcrlf at the end of .command -> no difference).
This is what I get in the logfile:
*** OnConnect received, err = 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.22.150.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
Re: SSH towards Cisco
by wodDamir, Friday, March 18, 2011, 10:51 (4997 days ago) @ dirk
Dirk,
So basically, the only problem is that it doesn't disconnect?
I don't see Protocol set anywhere. Can you please set it to SSHAuto?
Regards,
Damba
Re: SSH towards Cisco
by dirk, Friday, March 18, 2011, 11:20 (4997 days ago) @ wodDamir
Dirk,
So basically, the only problem is that it doesn't disconnect?
I don't see Protocol set anywhere. Can you please set it to SSHAuto?
Regards,
Damba
Correct there is no disconnect, so my real code doesn't know that all went well and just waits....
The protocol is set when a combo is changed
[code] If Combo1.ListIndex = 0 Then
Ssh.Protocol = Raw
End If
If Combo1.ListIndex = 1 Then
Ssh.Protocol = Telnet
End If
If Combo1.ListIndex = 2 Then
Ssh.Protocol = SSH1
End If
If Combo1.ListIndex = 3 Then
Ssh.Protocol = SSH2
End If
If Combo1.ListIndex = 4 Then
Text2 = 22
Ssh.Protocol = SSHAuto
End If [/code]
Tried it with auto and with ssh1, same result
Re: SSH towards Cisco
by wodDamir, Friday, March 18, 2011, 15:14 (4997 days ago) @ dirk
Dirk,
Sorry for a slower response.
Is there any chance you could somehow allow us access to that device?
I'm responding slower because I was trying to get an IOS emulator to work locally but couldn't get it to work.
Getting us access would speed things up greatly.
Regards,
Damba
Re: SSH towards Cisco
by dirk, Friday, March 18, 2011, 16:49 (4997 days ago) @ wodDamir
Dirk,
Sorry for a slower response.
Is there any chance you could somehow allow us access to that device?
I'm responding slower because I was trying to get an IOS emulator to work locally but couldn't get it to work.
Getting us access would speed things up greatly.
Regards,
Damba
Let me see if I can get the firewall to redirect port 22 traffic to the router....
Re: SSH towards Cisco
by dirk, Friday, March 18, 2011, 17:07 (4997 days ago) @ dirk
Dirk,
Sorry for a slower response.
Is there any chance you could somehow allow us access to that device?
I'm responding slower because I was trying to get an IOS emulator to work locally but couldn't get it to work.
Getting us access would speed things up greatly.
Regards,
Damba
Let me see if I can get the firewall to redirect port 22 traffic to the router....
OK I can give you access, however don't want to give that info in a forum...can you mail me?
Re: SSH towards Cisco
by woddrazen, Friday, March 18, 2011, 17:09 (4997 days ago) @ dirk
Hi Dirk,
You can send ti to:
techsupport@weonlydo.com
Drazen
Re: SSH towards Cisco
by dirk, Friday, March 18, 2011, 17:13 (4997 days ago) @ woddrazen
Hi Dirk,
You can send ti to:techsupport@weonlydo.com
Drazen
Info send
Re: SSH towards Cisco
by dirk, Friday, March 18, 2011, 20:31 (4997 days ago) @ dirk
Just as an update for the forum:
I was using an older version of the component (2.6.2)
Updating to the latest version 2.9.6.148 solved the problem.
(could well be that the problem was already solved in a prior build, however updating to the latest was the most logical step).
Thanks you support@Weonlydo, you did a great job!