Mailing List Archive

Bug when using SSH on CatOS devices
Hi,

I'm using RANCID 2.3.1 to get config from a bunch of Cisco 6500 running
CatOS 6.4.

Login is via SSH (on FreeBSD 5.3 w/ OpenSSH 3.8.1p1).

cat5rancid has the following code at around line 1062:

TOP: while(<INPUT>) {
tr/\015//d;
if (/> \(enable\) ?exit$/) {
$clean_run=1;
last;
}

where $clean_run would be set to true if the prompt matches 'exit'.
However when using SSH the exit becomes:

Switch> (enable)Connection to switch.foo.bar closed by remote host.
Connection to switch.foo.bar closed.

compared to this using telnet:

Switch> (enable)exit
Connection closed by foreign host.

which will match and set $clean_run to true. Hence $clean_run will
remain false when using SSH, making cat5rancid fail.

A quick hack is to just do '$clean_run = 1' at the end of the while()
loop, but it doesn't fix it for real.

Any ideas?

Thanks,
/Michael

--
Michael Lyngb?l -- michael at lyngbol dot dk
Network Architect, AS3292 TDC, IP?backbone
Bug when using SSH on CatOS devices [ In reply to ]
Tue, Oct 26, 2004 at 01:33:33PM +0200, Michael Lyngb?l:
> Hi,
>
> I'm using RANCID 2.3.1 to get config from a bunch of Cisco 6500 running
> CatOS 6.4.
>
> Login is via SSH (on FreeBSD 5.3 w/ OpenSSH 3.8.1p1).
>
> cat5rancid has the following code at around line 1062:
>
> TOP: while(<INPUT>) {
> tr/\015//d;
> if (/> \(enable\) ?exit$/) {
> $clean_run=1;
> last;
> }
>
> where $clean_run would be set to true if the prompt matches 'exit'.
> However when using SSH the exit becomes:
>
> Switch> (enable)Connection to switch.foo.bar closed by remote host.
> Connection to switch.foo.bar closed.

does it do this when you ssh in manually?

> compared to this using telnet:
>
> Switch> (enable)exit
> Connection closed by foreign host.
>
> which will match and set $clean_run to true. Hence $clean_run will
> remain false when using SSH, making cat5rancid fail.
>
> A quick hack is to just do '$clean_run = 1' at the end of the while()
> loop, but it doesn't fix it for real.
>
> Any ideas?
>
> Thanks,
> /Michael
>
> --
> Michael Lyngb?l -- michael at lyngbol dot dk
> Network Architect, AS3292 TDC, IP?backbone
Bug when using SSH on CatOS devices [ In reply to ]
On 27.10.2004 16:49:53 +0000, john heasley wrote:

> > I'm using RANCID 2.3.1 to get config from a bunch of Cisco 6500 running
> > CatOS 6.4.
> >
> > Login is via SSH (on FreeBSD 5.3 w/ OpenSSH 3.8.1p1).
> >
> > cat5rancid has the following code at around line 1062:
> >
> > TOP: while(<INPUT>) {
> > tr/\015//d;
> > if (/> \(enable\) ?exit$/) {
> > $clean_run=1;
> > last;
> > }
> >
> > where $clean_run would be set to true if the prompt matches 'exit'.
> > However when using SSH the exit becomes:
> >
> > Switch> (enable)Connection to switch.foo.bar closed by remote host.
> > Connection to switch.foo.bar closed.
>
> does it do this when you ssh in manually?

Yes, eg. when I do:

clogin -c 'sh ver' switch.foo.bar

/Michael

--
Michael Lyngb?l -- michael at lyngbol dot dk
Network Architect, AS3292 TDC, IP?backbone
Bug when using SSH on CatOS devices [ In reply to ]
Thu, Oct 28, 2004 at 09:13:26AM +0200, Michael Lyngb?l:
> On 27.10.2004 16:49:53 +0000, john heasley wrote:
>
> > > I'm using RANCID 2.3.1 to get config from a bunch of Cisco 6500 running
> > > CatOS 6.4.
> > >
> > > Login is via SSH (on FreeBSD 5.3 w/ OpenSSH 3.8.1p1).
> > >
> > > cat5rancid has the following code at around line 1062:
> > >
> > > TOP: while(<INPUT>) {
> > > tr/\015//d;
> > > if (/> \(enable\) ?exit$/) {
> > > $clean_run=1;
> > > last;
> > > }
> > >
> > > where $clean_run would be set to true if the prompt matches 'exit'.
> > > However when using SSH the exit becomes:
> > >
> > > Switch> (enable)Connection to switch.foo.bar closed by remote host.
> > > Connection to switch.foo.bar closed.
> >
> > does it do this when you ssh in manually?
>
> Yes, eg. when I do:
>
> clogin -c 'sh ver' switch.foo.bar

I meant "ssh switch.foo.bar"
Bug when using SSH on CatOS devices [ In reply to ]
On 28.10.2004 16:20:51 +0000, john heasley wrote:

> > > > I'm using RANCID 2.3.1 to get config from a bunch of Cisco 6500 running
> > > > CatOS 6.4.
> > > >
> > > > Login is via SSH (on FreeBSD 5.3 w/ OpenSSH 3.8.1p1).
> > > >
> > > > cat5rancid has the following code at around line 1062:
> > > >
> > > > TOP: while(<INPUT>) {
> > > > tr/\015//d;
> > > > if (/> \(enable\) ?exit$/) {
> > > > $clean_run=1;
> > > > last;
> > > > }
> > > >
> > > > where $clean_run would be set to true if the prompt matches 'exit'.
> > > > However when using SSH the exit becomes:
> > > >
> > > > Switch> (enable)Connection to switch.foo.bar closed by remote host.
> > > > Connection to switch.foo.bar closed.
> > >
> > > does it do this when you ssh in manually?
> >
> > Yes, eg. when I do:
> >
> > clogin -c 'sh ver' switch.foo.bar
>
> I meant "ssh switch.foo.bar"

Oh, sorry. No:

Switch> (enable) exitConnection to switch.foo.bar closed by remote host.
Connection to switch.foo.bar closed.

/Michael

--
Michael Lyngb?l -- michael at lyngbol dot dk
Network Architect, AS3292 TDC, IP?backbone
Bug when using SSH on CatOS devices [ In reply to ]
Hi Michael,
Don't know if anyone responded, but I've seen similar problems on older
Extremes when it would omit EOL(s) at random places.

In this case, it looks like CatOS or the SSH client is omitting/munging the
terminal's last \r\n based on your line:

My solution for Extreme's was a bit of a hack, but it went something like
the additional lines below. Don't think it is worth putting in a patch
unless this is a more common problem, but rather just a one off
solution. I forget if you need to put in a \n to make the file diff
correctly or not, but you might need to re-output the line too if it is not
100% consistent.

Hope this helps...
TOP: while(<INPUT>) {
tr/\015//d;
if (/> \(enable\) ?exit$/) {
$clean_run=1;
last;
}
# Check and see if it was a "less clean" run.
elsif (/> \(enable\) ?exitConnection to (\S+) closed by remote host\./){
$clean_run=1;
last;
}
}



At 12:04 PM 10/31/2004, Michael Lyngb?l wrote:
>On 28.10.2004 16:20:51 +0000, john heasley wrote:
>
> > > > > I'm using RANCID 2.3.1 to get config from a bunch of Cisco 6500
> running
> > > > > CatOS 6.4.
> > > > >
> > > > > Login is via SSH (on FreeBSD 5.3 w/ OpenSSH 3.8.1p1).
> > > > >
> > > > > cat5rancid has the following code at around line 1062:
> > > > >
> > > > > TOP: while(<INPUT>) {
> > > > > tr/\015//d;
> > > > > if (/> \(enable\) ?exit$/) {
> > > > > $clean_run=1;
> > > > > last;
> > > > > }
> > > > >
> > > > > where $clean_run would be set to true if the prompt matches 'exit'.
> > > > > However when using SSH the exit becomes:
> > > > >
> > > > > Switch> (enable)Connection to switch.foo.bar closed by remote
> host.
> > > > > Connection to switch.foo.bar closed.
> > > >
> > > > does it do this when you ssh in manually?
> > >
> > > Yes, eg. when I do:
> > >
> > > clogin -c 'sh ver' switch.foo.bar
> >
> > I meant "ssh switch.foo.bar"
>
>Oh, sorry. No:
>
>Switch> (enable) exitConnection to switch.foo.bar closed by remote host.
>Connection to switch.foo.bar closed.