Crypto ssh how to read the stdout pipe end?

Oh my lord. The bytes read from StdoutPipe is not line by line! :cry:

[line]   inspect skinny
  inspect esmtp

[line]   inspect sqlnet

[line]   inspect sunrpc
  inspect tftp

[line]   inspect sip
  inspect xdmcp

[line] policy-map type inspect dns migrated_dns_map_2
 parameters

[line]   message-length maximum client auto
  message-length maximum 512
  no tcp-inspection
!
service-policy global_policy global
prompt hostname context
no call-home reporting anonymous
call-home
 profile CiscoTAC-1
  no active
  destination address http https://tools.cisco.com/its/service/oddce/services/DDCEService
  destination address email callhome@cisco.com
  destination transport-method http
  subscribe-to-alert-group diagnostic
  subscribe-to-alert-group environment
  subscribe-to-alert-group inventory periodic monthly
  subscribe-to-alert-group configuration periodic monthly
  subscribe-to-alert-group telemetry periodic daily
 profile License
  destination address http https://tools.cisco.com/its/service/oddce/services/DDCEService

[line]   destination transport-method http
Cryptochecksum:f615c78cc7913affb2f486489897b63e
: end

9dadcd0b-75f4-4a71-8a95-6f08c18d761c(config)#

Last line which end with prompt matched the prompt pattern, so this line was ignored by the code pasted above.

9dadcd0b-75f4-4a71-8a95-6f08c18d761c(config)#

1 Like

If you need to read lines, use bufio.Scanner.

Ok, i will try.

1 Like

How to disable echoing?

var (
    modes = cssh.TerminalModes{
        cssh.ECHO:          0,     // disable echoing
        cssh.TTY_OP_ISPEED: 14400, // input speed = 14.4kbaud
        cssh.TTY_OP_OSPEED: 14400, // output speed = 14.4kbaud
    }
)
if err := session.RequestPty("xterm", 0, 0, modes); err != nil {
    return nil, err
}

Set TerminalModes is helpless. The output read from StdoutPipe contains what we written to StdinPipe

1 Like

Stop requesting a Pty, that is what is causing the remote end to think you are human and doing unhelpful things like pagination and echo.

With that said, we’ve already established that the cisco remote side is not really a shell so maybe it doesn’t behave like we hope.

You might have to filter out your input when it is returned to you.

I know there are lots of these types of programs wirtten in python and Perl, I’d recommend reading their source to understand how they worked around the unfriendly cisco console

I wrote and use this (mlxsh) almost all time in managing my Brocade routers. May also work for your Cisco if login is comparable. Take a look at the function readTill:

Jörg

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.