Hi Vern,
Okay, I have a solution for you, and I have tested this with our own FWSM and it works:
CPAN::Forum
Net-Appliance-Session - Re: Net-Appliance-Session 0.15 How do I handle session authentication
| Posted on Sat Jan 19 23:51:36 2008 by oliver in response to 6845 (See the whole thread of 3) |
| Re: Net-Appliance-Session 0.15 How do I handle session authentication |
|
Hi Vern, Okay, I have a solution for you, and I have tested this with our own FWSM and it works:
1 my $s = Net::Appliance::Session->new(
2 Host => '10.10.10.10',
3 );
4 $s->input_log(*STDOUT);
5
6 eval {
7 $s->connect(
8 Name => 'username',
9 Password => '********',
10 SHKC => 0,
11 );
12 $s->begin_privileged('********');
13
14 $s->cmd(
15 String => 'session slot 6 proc 1',
16 Match => ['/Password:/']
17 );
18 $s->cmd("********");
19
20 $s->in_privileged_mode(0);
21 $s->begin_privileged("********");
22 $s->cmd("quit");
23 };
24 print "error on $host: $@\n" if $@;
25
26 $s->close;
I'll quickly explain what is going on here. If you want more explanation, please just ask. I start by going into enable mode on the main switch using begin_privileged (12). Then I use the custom "cmd" method to session onto the FWSM (14), which allows me to override the match prompt and instead make the module stop when it sees a given regular expression, which is '/Password:/' (16). After that I have to enter the FWSM login password using a "cmd" (18). Okay, now for the part which is not documented :-) I am able to pass a false value to "in_privileged_mode" (20) to make the module once again think it is not in enable mode (which it isn't, for the FWSM). I can then make another call to "begin_privileged" (21) with the FWSM enable password (and username, if you want, also). To quit cleanly, I have to call "cmd" to log out of the FWSM (22), and then I can call "close" to log out of the switch (26). One thing you might need to watch out for is passing explicit passwords to begin_privileged on line 21, because your FWSM password may be different from your swtich password. I hope that helps! regards, oliver. |
| Write a response |
(0)
]