Tag Archives: passphrase

Cisco Wireless Controller – WPA PSK passphrase change Script and HTTP Publish



use Net::SSH::Expect;

my $ssh = Net::SSH::Expect->new (
 host => "",
 raw_pty => 1

my $pass = generatePassword(10);
print ("Generating new WPA passphrase: ".$pass."\n");
print ("Getting into WLC...\n");
$ssh->run_ssh() or die "SSH process couldn't start: $!";
$ssh->waitfor('User:', 10) or die "prompt 'User' not found after 10 second";
$ssh->waitfor('Password:', 3) or die "prompt 'Password' not found after 3 second";
$ssh->waitfor('(Cisco Controller)', 3) or die "prompt 'Cisco Controller' not found";
print ("Disabling SSID Wlan\n");
$ssh->exec("config wlan disable 7");
print ("Setting passphrase to SSID Wlan\n");
$ssh->exec("config wlan security wpa akm psk set-key ascii $pass 7");
print ("Enabling SSID Wlan\n");
$ssh->exec("config wlan enable 7");

open (MYFILE, '>temp.txt');
my $html_prefix = '<strong><font size="12">';
my $html_suffix = '</font></strong>';
print MYFILE ($html_prefix.$pass.$html_suffix."\n");
close (MYFILE);
system("cp -rf temp.txt /var/www/html/wireless/index.html");
print ("Job done!\n");

sub generatePassword {
$length = shift;
$possible = 'abcdefghijkmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
while (length($password) < $length)
 { $password .= substr($possible, (int(rand(length($possible)))), 1);
return $password