-
Notifications
You must be signed in to change notification settings - Fork 42
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
CiscoIOSXE Authentication fails when login banner does not end with blank line #65
Comments
output w/ logging enabled:
Also worth noting, but not really related(although this sent me troubleshooting wrong thing for a while) (not sure if this was intentional or not) in
|
Hey Denis! Thanks for raising this and for including all the detail/logs! Regarding the pattern stuff: probably the quickest fix is to use At this moment there isn't a way (short of updating yourself in source) to patch the patterns. In the python version we can update by just reaching into the channel like All that said, I defo would like to find a way to at least have it be user settable as in the python flavor of scrapli -- I'll leave this open to noodle on that (or you are welcome to take a crack at a pr on it if you're keen).
^^ regarding this -- can you elaborate a bit (maybe I need more caffeine -- its still reasonably early lol). I can defo see how returning nil from the channel authentication bits would be bad, but I'm not 100% on how that happened in your log output. Looks like it finds password prompt then just bailed out/moved on? I tested w/ localhost that if I have a bad password or something like that the channel auth returns a non-nil value, so that small test seems to work as expected. But clearly based on the log output there is something im missing! Thanks again for raising this and all the detail! Carl |
"probably the quickest fix is to use standard transport" sounds good I will give that a test this weekend "the multiline flag (the part that is breaking this basically) has tended to be a good thing to help prevent accidentally matching on stuff in banners and stuff." that makes sense "(or you are welcome to take a crack at a pr on it if you're keen)." I'll noodle on this as well..I'm just starting to scratch the surface with go, much more comfortable in python (but digging my go experience so far), if I come up with any brilliant ideas I'll take a crack at it, but as of now I don't have anything good.... As for the second part (which should perhaps be a separate issue?) here is what is happening:
At Point B we run the authentication function, this is where it times out because the password prompt is never matched, so, at this point, authErr is not nil, it contains an error, so at Point C the if statement evaluates to true, and at point D we return err. however, err at this point will always be nil, because, at point A is the last time err was set, and if it was not nil it would of returned out at that point. So this return will always return nil. So once it returns back to the calling function from step 3, err will not get the authentication error message, as such the the
on the debug posted above these lines from the middle show the results, in the second last line we see it receive the password prompt. This is the point where we failed, the password was never entered in as the authentication timed out, however, instead of stopping and printing out the error at this point it continued on to the OnOpen step which I believe is where the "attempting to acquire privilege level: privilege_exec" the following debug (not posted below but in original message) shows a write and password re-prompt. I assume it sen "en" or something to that extent but have not validated that
|
Hi @carlmontanari Just wondering what magic does system transport have at this point |
system transport is a fancy subprocess wrapper around /bin/ssh basically -- so "yeah" it is of course still doing auth, but its gotta literally hunt for the password prompt and such, whereas the "real" ssh clients are doing that stuff in some magic channel prior to just spewing bits to the clients terminal. As for solving it... the obvious fix (that I don't really want to do) would be to drop that multiline flag so the pattern finds the prompt even in this case w/ the banner ending and having the prompt run up into it. will dig into the extra bits Denis wrote this weekend but wanted to reply to that since I had a sec! |
confirmed changing to use |
doing some more debugging on the regex matching... To make it easier to work with, shortened the banner to:
in
found a few options for how to match this, nothing really creative... mostly changing the pattern from |
@dpnetca thanks for spelling that out (re the authErr thing) I was just blind and not seeing it! I've opened #66 to address both the authErr and providing the option to pass in patterns to override the default for password/passphrase and username (telnet). I'm not super wild about how scrapligo is structured (it was my first real attempt at a go project), and I don't super love this, but I think it addresses the issues so at least for now until I maybe eventually do a big overhaul this should do the trick! I'll close this now so we can move the convo over to the PR -- if you could let us all know if this sorts both of those issues out or not there that would be much appreciated! Thanks again for the issue and all the detail! Carl |
@dpnetca I'm going to end up removing that newline anchor I think.... too many folks won't get logs and do some investigating like you did and I think it'll end up being more of a problem than the thing the newline anchor tries to prevent! thanks again for the work on digging into this! |
When connecting to a Cisco IOSXE device (have not tested with others) that contains a login banner, where the login banner does not end on a blank line, the SSH Authentication times out as the
passwordPattern
infunc GetAuthPatterns()
is not matchedExample with IOSv that ships with Cisco CML, out of the box, the default login banner configuration is this:
because the banner does not end on a blank line the password prompt appear in a format that does not match the regular expression for the passwordPattern defined in
func GetAuthPatterns()
:passwordPattern: regexp.MustCompile(`(?im)^(.*@.*)?password:\s?$`),
removing the banner, or Changing the banner as follows does solve this problem:
However, could this also be solved by changing the password prompt regex? Changing the pattern to:
passwordPattern: regexp.MustCompile(`(?im)^(.*)?password:\s?$`),
does solve the problem, but not sure if that will cause other issues (if there was use cases that required the.*@.*
to match instead of just.*
)?alternatively, is there the ability to pass a custom regex for this prompt in anywhere?
The text was updated successfully, but these errors were encountered: