init
This commit is contained in:
63
rancid/pw.pl
Executable file
63
rancid/pw.pl
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use IO::Prompter;
|
||||
|
||||
my $ok;
|
||||
my $os;
|
||||
|
||||
my ($cmd, $cmc, $style);
|
||||
my ($admin,$adminpw);
|
||||
my ($user,$userpw,$userhash);
|
||||
|
||||
chdir ("/home/rancid/var/rancid/network/configs");
|
||||
|
||||
do {
|
||||
$os = prompt("\nGerätetyp :", -guarantee => [ 'nxos', 'ios', 'asa', 'alle' ] );
|
||||
|
||||
$admin = prompt("\nAdmin :");
|
||||
$adminpw = prompt('Admin Passwort :', -echo => '*');
|
||||
$style = prompt("\nUser Passwort in Klartext? (Bei nein ein Hash):", -yn1);
|
||||
|
||||
$user = prompt("\nUser :");
|
||||
if ($style eq 'y') {
|
||||
$userpw = prompt('User Passwort :', -echo => '*');
|
||||
}
|
||||
if ($style eq 'n') {
|
||||
$userhash = prompt('User Hash :');
|
||||
}
|
||||
$ok = prompt("\nEingabe korrekt :", -yn1);
|
||||
} while ($ok eq 'n');
|
||||
|
||||
print "\n";
|
||||
my @files=glob("*");
|
||||
|
||||
foreach my $file (@files) {
|
||||
$cmd="clogin -u $admin -p $adminpw -c";
|
||||
|
||||
if ($file =~ /^switch-nexus-/ or $file =~ /^switch-fibre-/) {
|
||||
if ( $os eq 'nxos' or $os eq 'alle') {
|
||||
$cmc='"conf t\nusername ' . "$user" . ' password 0 ' . "$userpw" . ' role network-admin\n\nend\ncopy run start\n\n"' if($style eq 'y');
|
||||
$cmc='"conf t\nusername ' . "$user" . ' password 5 ' . "$userhash" . ' role network-admin\n\nend\ncopy run start\n\n"' if($style eq 'n');
|
||||
print "$file\n";
|
||||
`$cmd $cmc $file`; #print "$cmd $cmc $file\n";
|
||||
}
|
||||
}
|
||||
elsif ($file =~ /^router-/ or $file =~ /^switch-/ ) {
|
||||
if ( $os eq 'ios' or $os eq 'alle') {
|
||||
$cmc='"conf t\nusername ' . "$user" . ' privilege 15 view root password 0 ' . "$userpw" . '\n\nend\ncopy run start\n\n"' if($style eq 'y');
|
||||
$cmc='"conf t\nusername ' . "$user" . ' privilege 15 view root password 7 ' . "$userhash" . '\n\nend\ncopy run start\n\n"' if($style eq 'n');
|
||||
print "$file\n";
|
||||
`$cmd $cmc $file`; #print "$cmd $cmc $file\n";
|
||||
}
|
||||
}
|
||||
elsif ($file =~ /^asa-/) {
|
||||
if ( $os eq 'asa' or $os eq 'alle') {
|
||||
$cmc='"conf t\nusername ' . "$user" . ' password ' . "$userpw" . ' privilege 15\n\nend\ncopy run start\n\n"' if ($style eq 'y');
|
||||
$cmc='"conf t\nusername ' . "$user" . ' password ' . "$userhash" . ' encrypted privilege 15\n\nend\ncopy run start\n\n"' if ($style eq 'n');
|
||||
print "$file\n";
|
||||
`$cmd $cmc $file`; #print "$cmd $cmc $file\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user