PABX da Simples IP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
945 B

<?php
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("localhost", 22))) {
echo "fail: unable to establish connection\n";
} else { // try to authenticate with username root, password secretpassword
if (!ssh2_auth_password($con, "root", "admin123@a$sterisk")) {
echo "fail: unable to authenticate\n";
} else {
echo "okay: logged in...\n";
if (!($shell = ssh2_shell($con, 'vt102', null, 80, 40, SSH2_TERM_UNIT_CHARS))) {
echo "fail: unable to establish shell\n";
} else {
stream_set_blocking($shell, true);
fwrite($shell, "ls -al\n");
sleep(1);
$data = "";
while ($buf = fread($shell, 4096)) {
$data .= $buf;
}
fclose($shell);
}
}
}
?>