I'm trying to reach Cisco device and run authcache command remotely. The script has to log in and run following stuff:
authcache > flushall > y
<?php
if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
if(!($con = ssh2_connect("****", 22))){
echo "fail: unable to establish connection\n";
} else {
if(!ssh2_auth_password($con, "****", "****")) {
echo "fail: unable to authenticate\n";
} else {
$stream = shell_exec("authcache");
$stream = shell_exec("flushall");
$stream = shell_exec("y");
echo $stream;
}
}
Directly on the Cisco box it looks following:
ciscobox.com> authcache
Choose the operation you want to perform: - FLUSHALL - Flush all entries from auth cache - FLUSHUSER - Flush specific user entry from auth cache - LIST - List all entries from auth cache - SEARCH - Search all entries from auth cache []> flushall
Are you sure that you want to flush all entries? [Y]> y
In the nutshell, the logic for that is to send command "authcache" and afterwards under the same command two subcommands "flushall" and "y" for confirmation.
Do you guys have any idea how I could achieve this kind of method to run two sub-command under the main command over the php script?
How could we achieve to forward authcache command with all parameters including to clear the authcache?
Thank you