Page 1 of 1

SSH to Cisco ASA

Posted: Fri Sep 24, 2010 3:24 pm
by Slowfib
I've been working on a script on and off for a while to SSH to a Cisco ASA and run some commands. I'm able to login to the device just fine, but I haven't had any luck getting any results back from my commands.

I'm not sure I'm using the stream_set_blocking function correctly because sometimes I get a bit of data if I run the script twice and alternative between setting stream_set_blocking to true or false. After I get 1 line sometimes, the connection seems to just drop after that.

Code: Select all

$ssh = ssh2_connect($ip, 22);
if (!ssh2_auth_password($ssh, $username, $password)) {
   exit('Login Failed');
}
$vpncmd = "?";
$stream = ssh2_exec($ssh, $vpncmd) or die("error");
stream_set_blocking($stream, false);
$data = "";
while ($buf = fread($stream, 4096)) {
   $data .= $buf;
}
fclose($stream);
echo $data;
If anyone has any suggestions, I'd really appreciate it. Or if there is a way to display SSH's debug info on the connection status and could troubleshoot that.

Or if there's even some way I can push all my commands through Putty.exe :)

Thank you!