<div dir="ltr"><div><div><div>Hey,<br><br></div>back in 2006 there was a patch on this list: <a href="http://www.shrubbery.net/pipermail/rancid-discuss/2006-May/001490.html">http://www.shrubbery.net/pipermail/rancid-discuss/2006-May/001490.html</a>. We are still using this patch even today with rancid-3.2. With this you can tweak your .cloginrc to switch the context on login. Each contexts is treated as a separate device:<br><br></div><div># Base login for the asa-01 device<br></div><div>add user asa-01 username<br>add password asa-01 password password<br>add method asa-01 {ssh:22}<br>add autoenable asa-01 {0}<br>add cyphertype asa-01 3DES<br><br></div><div># Login to admin on asa-01</div><div>add method asa-01-admin {usercmd}<br>add usercmd asa-01-admin {clogin} {asa-01}<br>add usercmd_chat asa-01-admin {asa-01/admin#} {changeto system\r} {asa-01#} {changeto context admin\r} {asa-01/admin#} {\r}<br><br></div><div># Login to fwcontext on asa-01<br></div><div>add method asa-01-fwcontext {usercmd}<br>add usercmd asa-01-fwcontext {clogin} {asa-01}<br>add usercmd_chat asa-01-fwcontext {asa-01/admin#} {changeto system\r} {asa-01#} {changeto context fwcontext\r} {asa-01/fwcontext#} {\r}<br><br><br></div><div>With this you can do 'clogin asa-01-fwcontext'.<br><br></div>Regards,<br></div>Daniel<br><div><div><div><div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-11-18 7:51 GMT+01:00 <a href="mailto:christian.filips@tu-dortmund.de">christian.filips@tu-dortmund.de</a> <span dir="ltr"><<a href="mailto:christian.filips@tu-dortmund.de" target="_blank">christian.filips@tu-dortmund.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I found a working solution:<br>
<br>
/usr/lib/rancid/bin/clogin -c 'terminal pager 0;changeto context admin\rchangeto context system;sh running-config\rexit'<br>
<br>
The prompt seems not to be the problem, the problem appears at the "changeto"!<br>
I saw, that it worked with the actual logged-in-user: "admin# changeto context admin" No timeout!<br>
So i tried it with the actual one and DIRECTLY with a "return" (\r) behind it an change tu the system context - this works, without ";"!<br>
The same problem later in the commands, so i type also a \r at before the "exit". Fine!<br>
<br>
Now i can work with the script.<br>
Thanks and greetings.<br>
:-)<br>
<br>
<br>
-----Ursprüngliche Nachricht-----<br>
Von: Rancid-discuss [mailto:<a href="mailto:rancid-discuss-bounces@shrubbery.net">rancid-discuss-bounces@shrubbery.net</a>] Im Auftrag von Howard Jones<br>
Gesendet: Dienstag, 17. November 2015 22:17<br>
An: <a href="mailto:rancid-discuss@shrubbery.net">rancid-discuss@shrubbery.net</a><br>
Betreff: Re: [rancid] RANCID/clogin context-change FWSM/ASA<br>
<div class="HOEnZb"><div class="h5"><br>
I did look at this a while ago and there was also a change required in clogin so that the expect script also looked for a wider variety prompt.<br>
<br>
On 17/11/15 20:58, Alan McKinnon wrote:<br>
> The code that does it usually looks something like this in main() (it<br>
> can be different for each *rancid parser script):<br>
><br>
> if (!defined($prompt)) {<br>
> $prompt = ($_ =~ /^([^#>]+[#>])/)[0];<br>
> $prompt =~ s/([][}{)(\\])/\\$1/g;<br>
> print STDERR ("PROMPT MATCH: $prompt\n") if ($debug);<br>
> }<br>
><br>
> This should do the right thing:<br>
><br>
> $prompt = ($_ =~ /^([^#>]+[#>])\s*$/)[0];<br>
><br>
> That will skip the first two prompts in your output below and pick the<br>
> 3rd, and correct, one. To work, the FSWM prompt must behave<br>
> predictably like this.<br>
><br>
><br>
> On 17/11/2015 17:51, Lee Rian (CENSUS/TCO FED) wrote:<br>
>>> What could be the problem here?<br>
>><br>
>> RANCID looks for the prompt. If it doesn't see it you get a timeout<br>
>><br>
>><br>
>> I'm going to guess the problem is the prompt is different in the<br>
>> system context. I just tried it & got:<br>
>><br>
>><br>
>> asaname/admin> ena<br>
>> Password: ****************<br>
>> asaname/admin# changeto context system asaname#<br>
>><br>
>><br>
>> & no, sorry, I don't know how to deal with the prompt changing on you<br>
>> like that.<br>
>><br>
>><br>
>> Regards,<br>
>><br>
>> Lee<br>
>><br>
>><br>
>><br>
>><br>
>> ------------------------------------------------------------------------<br>
>> *From:* Rancid-discuss <<a href="mailto:rancid-discuss-bounces@shrubbery.net">rancid-discuss-bounces@shrubbery.net</a>> on behalf<br>
>> of <a href="mailto:christian.filips@tu-dortmund.de">christian.filips@tu-dortmund.de</a> <<a href="mailto:christian.filips@tu-dortmund.de">christian.filips@tu-dortmund.de</a>><br>
>> *Sent:* Tuesday, November 17, 2015 4:26 AM<br>
>> *To:* <a href="mailto:rancid-discuss@shrubbery.net">rancid-discuss@shrubbery.net</a><br>
>> *Subject:* [rancid] RANCID/clogin context-change FWSM/ASA<br>
>><br>
>><br>
>> Hello all!<br>
>><br>
>><br>
>><br>
>> I have the problem to change the context after login into a Cisco FWSM.<br>
>><br>
>> This is my clogin-command:<br>
>><br>
>><br>
>><br>
>> =============<br>
>><br>
>> rancid@host:$ /usr/lib/rancid/bin/clogin -c 'terminal pager 0; changeto<br>
>> context system;sh running-config;exit' asa-address<br>
>><br>
>> asa-address<br>
>><br>
>> spawn ssh -c 3des -x -l cisco_login asa-address<br>
>><br>
>> login@asa-address's password:<br>
>><br>
>> Type help or '?' for a list of available commands.<br>
>><br>
>> asa-address/admin> enable<br>
>><br>
>> Password:<br>
>><br>
>> asa-address/admin#<br>
>><br>
>> asa-address/admin# terminal length 0<br>
>><br>
>> ^<br>
>><br>
>> ERROR: % Invalid input detected at '^' marker.<br>
>><br>
>> asa-address/admin# terminal width 132<br>
>><br>
>> ^<br>
>><br>
>> ERROR: % Invalid input detected at '^' marker.<br>
>><br>
>> asa-address/admin# terminal pager 0<br>
>><br>
>> asa-address/admin# changeto context system<br>
>><br>
>><br>
>><br>
>> Error: TIMEOUT reached<br>
>><br>
>> rancid@host:$<br>
>><br>
>> =============<br>
>><br>
>><br>
>><br>
>> The timeout appears at nearly 45 seconds.<br>
>><br>
>> -<br>
>><br>
>> I tried to find out something with the -d option, but it looks ok.<br>
>><br>
>> I could mail, if useful, the output also.<br>
>><br>
>> -<br>
>><br>
>> I ran this on a ASA 5585, and it works fine there!<br>
>><br>
>> Also for our Switches (without context-change ;-)).<br>
>><br>
>> What could be the problem here?<br>
>><br>
>><br>
>><br>
>> Thanks for help or new ideas!<br>
>><br>
>> BR<br>
>><br>
>> Christian<br>
>><br>
>> /Wichtiger Hinweis: Die Information in dieser E-Mail ist vertraulich.<br>
>> Sie ist ausschließlich für den Adressaten bestimmt. Sollten Sie nicht<br>
>> der für diese E-Mail bestimmte Adressat sein, unterrichten Sie bitte den<br>
>> Absender und vernichten Sie diese Mail. Vielen Dank.<br>
>> Unbeschadet der Korrespondenz per E-Mail, sind unsere Erklärungen<br>
>> ausschließlich final rechtsverbindlich, wenn sie in herkömmlicher<br>
>> Schriftform (mit eigenhändiger Unterschrift) oder durch Übermittlung<br>
>> eines solchen Schriftstücks per Telefax erfolgen.<br>
>><br>
>> Important note: The information included in this e-mail is confidential.<br>
>> It is solely intended for the recipient. If you are not the intended<br>
>> recipient of this e-mail please contact the sender and delete this<br>
>> message. Thank you. Without prejudice of e-mail correspondence, our<br>
>> statements are only legally binding when they are made in the<br>
>> conventional written form (with personal signature) or when such<br>
>> documents are sent by fax. /<br>
>><br>
>><br>
>> _______________________________________________<br>
>> Rancid-discuss mailing list<br>
>> <a href="mailto:Rancid-discuss@shrubbery.net">Rancid-discuss@shrubbery.net</a><br>
>> <a href="http://www.shrubbery.net/mailman/listinfo/rancid-discuss" rel="noreferrer" target="_blank">http://www.shrubbery.net/mailman/listinfo/rancid-discuss</a><br>
>><br>
><br>
<br>
_______________________________________________<br>
Rancid-discuss mailing list<br>
<a href="mailto:Rancid-discuss@shrubbery.net">Rancid-discuss@shrubbery.net</a><br>
<a href="http://www.shrubbery.net/mailman/listinfo/rancid-discuss" rel="noreferrer" target="_blank">http://www.shrubbery.net/mailman/listinfo/rancid-discuss</a><br>
Wichtiger Hinweis: Die Information in dieser E-Mail ist vertraulich. Sie ist ausschließlich für den Adressaten bestimmt. Sollten Sie nicht der für diese E-Mail bestimmte Adressat sein, unterrichten Sie bitte den Absender und vernichten Sie diese Mail. Vielen Dank.<br>
Unbeschadet der Korrespondenz per E-Mail, sind unsere Erklärungen ausschließlich final rechtsverbindlich, wenn sie in herkömmlicher Schriftform (mit eigenhändiger Unterschrift) oder durch Übermittlung eines solchen Schriftstücks per Telefax erfolgen.<br>
<br>
Important note: The information included in this e-mail is confidential. It is solely intended for the recipient. If you are not the intended recipient of this e-mail please contact the sender and delete this message. Thank you. Without prejudice of e-mail correspondence, our statements are only legally binding when they are made in the conventional written form (with personal signature) or when such documents are sent by fax.<br>
_______________________________________________<br>
Rancid-discuss mailing list<br>
<a href="mailto:Rancid-discuss@shrubbery.net">Rancid-discuss@shrubbery.net</a><br>
<a href="http://www.shrubbery.net/mailman/listinfo/rancid-discuss" rel="noreferrer" target="_blank">http://www.shrubbery.net/mailman/listinfo/rancid-discuss</a></div></div></blockquote></div><br></div>