I've been trying to follow the example code found at:
http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/
I am able to connect to my switch, and successfully authenticate. BUt when I try to run a command, it fails with the error message in the title of this post.
if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
// log in at server1.example.com on port 22
if(!($con = ssh2_connect("10.14.123.12", 22))){
echo "fail: unable to establish connection
";
} else {
// try to authenticate with username root, password secretpassword
if(!ssh2_auth_password($con, "root", "mypassword")) {
echo "fail: unable to authenticate
";
} else {
// execute a command
if (!($stream = ssh2_exec($con, "show mac-address" ))) {
echo "fail: unable to execute command
";
} else {
stream_set_blocking($stream, true);
$data = "";
while ($buf = fread($stream,4096)) {
$data .= $buf;
}
fclose($stream);
}
}
}
It's dying on the line where I'm trying to execute the show mac-address command. I've confirmed that this is the correct syntax for the switch command - tried it manually...and it returns data just fine. Any suggestions? Thanks.