xalupeao
Verified User
ssh2_exec().
falls on a bucle, not receive a response ...
..............
php.ini
extension = ssh2.so [OK]
Plz help! me.
falls on a bucle, not receive a response ...
PHP:
<?
#obtenemos las variables
$ip = "xxx.xxx.xxx.xxx";
$puerto = "22";
$usuario = "root";
$password = "XXXXXX";
#nos conectamos al servidor
$conexion = ssh2_connect($ip,$puerto);
#probamos la conexion
if($conexion){
#enviamos el mensaje
print 'Se conecto al servidor '.$ip.' como '.$usuario.'<br>';
#autentificamos nuestro usuario
if(ssh2_auth_password($conexion,$usuario,$password)){
#enviamos el mensaje
print 'Se autentifico con exito<br>';
#ejecutamos el comandos
$load= ssh2_exec($conexion,'uptime',false);
stream_set_blocking($load, true);
$load = stream_get_contents($load);
#obtenemos el uptime
print $load;
$load = split("load average:", $load);
$load = split(", ", $load[1]);
$load = $load[0];
echo "Current Load: $load <br>";
}else{
#enviamos el mensaje
print 'La combinación usuario/contraseña no es correcta!<br>';
}
}else{
#enviamos el mensaje
print 'ERROR: al intentar conectar con el servidor '.$ip.'<br>';
}
?>
..............
[root@localhost]# php -m
[PHP Modules]
bcmath
calendar
ctype
curl
date
dom
filter
ftp
gd
gettext
hash
iconv
ionCube Loader
json
libxml
mbstring
mcrypt
mhash
mysql
mysqli
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
posix
Reflection
session
SimpleXML
sockets
SPL
SQLite
ssh2
standard
tokenizer
xml
xmlreader
xmlwriter
Zend Optimizer
zip
zlib
[Zend Modules]
Zend Extension Manager
Zend Optimizer
the ionCube PHP Loader
php.ini
extension = ssh2.so [OK]
Plz help! me.
Last edited: