Foros del Web » Administración de Sistemas » Unix / Linux »

Error instalando extensión ssh2 PHP en Centos 6

Estas en el tema de Error instalando extensión ssh2 PHP en Centos 6 en el foro de Unix / Linux en Foros del Web. hola amigos espero me puedan ayudar Actualmente necesito conectarme por SSH a través de PHP , este es mi codigo pero no obtengo nada en ...
  #1 (permalink)  
Antiguo 06/08/2013, 22:42
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Error instalando extensión ssh2 PHP en Centos 6

hola amigos espero me puedan ayudar

Actualmente necesito conectarme por SSH a través de PHP , este es mi codigo pero no obtengo nada en pantalla ni error

Código PHP:
Ver original
  1. <?php
  2.  
  3.  
  4. $server['ip'] = "127.0.0.1";
  5. $server['sshport'] = 22;
  6. $server['user'] = "root";  
  7. $server['pw'] =  "montes2012";
  8.  
  9. $command = "uname -a";
  10.  
  11.  
  12.  
  13. if($ssh = ssh2_conect($server_['ip'], $server['sshport'])){
  14.     var_dump($ssh);
  15.     if(ssh2_auth_password($ssh, $server['user'], $server['pw'])){
  16.         $stream = ssh2_exec($ssh,$command);
  17.         stream_set_blocking($stream,true);
  18.         $data = "";
  19.         while($buffer = fread ($stream, 4096))
  20.         {
  21.             $data .= $buffer;
  22.            
  23.         }
  24.         fclose($stream);
  25.         print $data;
  26.     }else{
  27.        
  28.         echo "Mensaje 1";
  29.     }
  30.    
  31.    
  32. }else{
  33.     echo "Mensaje 2";
  34.    
  35. }
  36. ?>

con phpinfo — Muestro información sobre la configuración de PHP

en la seccion de curl obtengo la extension
libSSH Version libssh2/1.4.2

estoy utilizando Centos 6
  #2 (permalink)  
Antiguo 07/08/2013, 00:19
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Error al conectarse por SSH a través de PHP

Y ya instalaste SSH en el servidor? http://www.techotopia.com/index.php/...cess_using_SSH
__________________
- León, Guanajuato
- GV-Foto
  #3 (permalink)  
Antiguo 07/08/2013, 00:29
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: Error al conectarse por SSH a través de PHP

hola triby gracias por responder , si tengo instalado el SSH en el servidor y el servicio esta arriba

Código BASH:
Ver original
  1. [root@Montes ~]# service sshd status
  2. Se está ejecutando openssh-daemon (pid  1624)...

creo que el problema es con la extension SSH2, pero he intentado instalarla pero no he podido es un poco complicado

obtengo estos errores
[HIGHLIGHT="BASH"]
[root@Montes ~]# php -v
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/ssh2.so' - /usr/lib/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.5.1 (cli) (built: Jul 24 2013 18:23:29)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
[/HIGHLIGHT

http://localhost/ssh/index.php
Fatal error: Call to undefined function ssh2_conect() in /var/www/html/ssh/index.php on line 14
  #4 (permalink)  
Antiguo 07/08/2013, 00:46
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Error al conectarse por SSH a través de PHP

Pues entonces el problema no es PHP en sí, sino la instalación de la extensión.

1- Revisa que ya tengas instalado openssl y libssh2: http://www.php.net/manual/es/ssh2.requirements.php
2- Actualiza repositorios rpm, descarga e instala ssh2 y reinicia apache: http://safesrv.net/global-system-mod...ling-php-ssh2/
__________________
- León, Guanajuato
- GV-Foto
  #5 (permalink)  
Antiguo 07/08/2013, 01:19
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: Error al conectarse por SSH a través de PHP

revisen en phpinfo openssl y libssh2 y obtengo

OpenSSL support enabled
libSSH Version libssh2/1.4.2

actualice los repositorios y no hubo problema
Código BASH:
Ver original
  1. rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
obtube el paquete rpmforge-release-0.5.2-2.el6.rf.i686 ya está instalado

Instalacion de libssh-dev
Código BASH:
Ver original
  1. [root@Montes ~]# yum install libssh2-devel
  2. Package libssh2-devel-1.4.2-1.el6.i686 already installed and latest version
  3. Nothing to do

instalar la extensión PHP-SSH2
Código BASH:
Ver original
  1. [root@Montes ~]# pecl install -f ssh2
  2.  
  3. Warning: Invalid argument supplied for foreach() in Command.php on line 259
  4.  
  5. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  6.  
  7. Warning: Invalid argument supplied for foreach() in Command.php on line 259
  8.  
  9. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  10.  
  11. Warning: Invalid argument supplied for foreach() in Command.php on line 259
  12.  
  13. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  14.  
  15. Warning: Invalid argument supplied for foreach() in Command.php on line 259
  16.  
  17. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  18.  
  19. Warning: Invalid argument supplied for foreach() in Command.php on line 259
  20.  
  21. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  22.  
  23. Warning: Invalid argument supplied for foreach() in Command.php on line 259
  24.  
  25. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  26.  
  27. Warning: Invalid argument supplied for foreach() in Command.php on line 259
  28.  
  29. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  30.  
  31. Warning: Invalid argument supplied for foreach() in Command.php on line 259
  32.  
  33. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  34.  
  35. Warning: Invalid argument supplied for foreach() in Command.php on line 259
  36.  
  37. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  38.  
  39. Warning: Invalid argument supplied for foreach() in Command.php on line 259
  40.  
  41. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  42.  
  43. Warning: Invalid argument supplied for foreach() in Command.php on line 259
  44.  
  45. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  46.  
  47. Notice: Undefined index: honorsbaseinstall in Role.php on line 180
  48.  
  49. Notice: Undefined index: honorsbaseinstall in Role.php on line 180
  50.  
  51. Notice: Undefined index: honorsbaseinstall in Role.php on line 180
  52.  
  53. Notice: Undefined index: honorsbaseinstall in Role.php on line 180
  54.  
  55. Notice: Undefined index: honorsbaseinstall in Role.php on line 180
  56.  
  57. Notice: Undefined index: honorsbaseinstall in Role.php on line 180
  58.  
  59. Notice: Undefined index: honorsbaseinstall in Role.php on line 180
  60.  
  61. Notice: Undefined index: honorsbaseinstall in Role.php on line 180
  62.  
  63. Notice: Undefined index: honorsbaseinstall in Role.php on line 180
  64.  
  65. Notice: Undefined index: installable in Role.php on line 145
  66.  
  67. Notice: Undefined index: installable in Role.php on line 145
  68.  
  69. Notice: Undefined index: installable in Role.php on line 145
  70.  
  71. Notice: Undefined index: installable in Role.php on line 145
  72.  
  73. Notice: Undefined index: installable in Role.php on line 145
  74.  
  75. Notice: Undefined index: installable in Role.php on line 145
  76.  
  77. Notice: Undefined index: installable in Role.php on line 145
  78.  
  79. Notice: Undefined index: installable in Role.php on line 145
  80.  
  81. Notice: Undefined index: installable in Role.php on line 145
  82.  
  83. Notice: Undefined index: phpfile in Role.php on line 212
  84.  
  85. Notice: Undefined index: phpfile in Role.php on line 212
  86.  
  87. Notice: Undefined index: phpfile in Role.php on line 212
  88.  
  89. Notice: Undefined index: phpfile in Role.php on line 212
  90.  
  91. Notice: Undefined index: phpfile in Role.php on line 212
  92.  
  93. Notice: Undefined index: phpfile in Role.php on line 212
  94.  
  95. Notice: Undefined index: phpfile in Role.php on line 212
  96.  
  97. Notice: Undefined index: phpfile in Role.php on line 212
  98.  
  99. Notice: Undefined index: phpfile in Role.php on line 212
  100.  
  101. Notice: Undefined index: config_vars in Role.php on line 49
  102.  
  103. Notice: Undefined index: config_vars in Role.php on line 49
  104.  
  105. Notice: Undefined index: config_vars in Role.php on line 49
  106.  
  107. Notice: Undefined index: config_vars in Role.php on line 49
  108.  
  109. Notice: Undefined index: config_vars in Role.php on line 49
  110.  
  111. Notice: Undefined index: config_vars in Role.php on line 49
  112.  
  113. Notice: Undefined index: config_vars in Role.php on line 49
  114.  
  115. Notice: Undefined index: config_vars in Role.php on line 49
  116.  
  117. Notice: Undefined index: config_vars in Role.php on line 49
  118.  
  119. Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 259
  120.  
  121. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  122.  
  123. Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 259
  124.  
  125. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  126.  
  127. Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 259
  128.  
  129. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  130.  
  131. Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 259
  132.  
  133. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  134.  
  135. Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 259
  136.  
  137. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  138.  
  139. Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 259
  140.  
  141. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  142.  
  143. Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 259
  144.  
  145. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  146.  
  147. Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 259
  148.  
  149. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  150.  
  151. Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 259
  152.  
  153. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  154.  
  155. Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 259
  156.  
  157. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  158.  
  159. Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 259
  160.  
  161. Warning: Invalid argument supplied for foreach() in /usr/share/pear/PEAR/Command.php on line 259
  162. XML Extension not found


reinicio apache
Código BASH:
Ver original
  1. service httpd restart

ejecute este comando
Código BASH:
Ver original
  1. [root@Montes ~]# php -m | grep ssh2
  2. PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/ssh2.so' - /usr/lib/php/modules/ssh2.so: cannot open shared object file: No such file or directory in Unknown on line 0

que estoy haciendo mal?
  #6 (permalink)  
Antiguo 07/08/2013, 04:08
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Error instalando extensión ssh2 PHP en Centos 6

Pues movemos tu tema a donde puedan orientarte mejor.

Tema movido desde PHP.
__________________
- León, Guanajuato
- GV-Foto
  #7 (permalink)  
Antiguo 07/08/2013, 09:39
Avatar de Carlangueitor
Moderador ლ(ಠ益ಠლ)
 
Fecha de Ingreso: marzo-2008
Ubicación: México
Mensajes: 10.037
Antigüedad: 16 años, 1 mes
Puntos: 1329
Respuesta: Error instalando extensión ssh2 PHP en Centos 6

Prueba instalarlo de esta manera: http://stackoverflow.com/questions/8...38640#15138640

Saludos
__________________
Grupo Telegram Docker en Español
  #8 (permalink)  
Antiguo 07/08/2013, 13:57
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: Error instalando extensión ssh2 PHP en Centos 6

Carlangueitor gracias por responder , segui los pasos que me indicaste pero no logro hacer la instalación satisfactoria

1.yum install automake make php-devel libtool openssl-devel gcc++ gcc
Código BASH:
Ver original
  1. [root@Montes ~]# yum install automake make php-devel libtool openssl-devel gcc++ gcc
  2. Loaded plugins: fastestmirror, refresh-packagekit
  3. Loading mirror speeds from cached hostfile
  4.  * base: mirror.edatel.net.co
  5.  * epel: mirror.globo.com
  6.  * extras: mirror.edatel.net.co
  7.  * updates: mirror.edatel.net.co
  8.  * webtatic: us-east.repo.webtatic.com
  9. Setting up Install Process
  10. Package automake-1.11.1-4.el6.noarch already installed and latest version
  11. Package 1:make-3.81-20.el6.i686 already installed and latest version
  12. Package libtool-2.2.6-15.5.el6.i686 already installed and latest version
  13. Package openssl-devel-1.0.0-27.el6_4.2.i686 already installed and latest version
  14. No package gcc++ available.
  15. Package gcc-4.4.7-3.el6.i686 already installed and latest version
  16. Resolving Dependencies
  17. --> Running transaction check
  18. ---> Package php-devel.i686 0:5.3.3-23.el6_4 will be installed
  19. --> Processing Dependency: php(x86-32) = 5.3.3-23.el6_4 for package: php-devel-5.3.3-23.el6_4.i686
  20. --> Finished Dependency Resolution
  21. Error: Package: php-devel-5.3.3-23.el6_4.i686 (updates)
  22.            Requires: php(x86-32) = 5.3.3-23.el6_4
  23.            Installed: php-5.5.1-1.el6.remi.i686 (@remi-test)
  24.                php(x86-32) = 5.5.1-1.el6.remi
  25.            Available: php-5.3.3-22.el6.i686 (base)
  26.                php(x86-32) = 5.3.3-22.el6
  27.            Available: php-5.3.3-23.el6_4.i686 (updates)
  28.                php(x86-32) = 5.3.3-23.el6_4
  29.  You could try using --skip-broken to work around the problem
  30.  You could try running: rpm -Va --nofiles --nodigest

2. cd /usr/lib/php
Código BASH:
Ver original
  1. [root@Montes ~]# cd /usr/lib/php
  2. [root@Montes php]# pwd
  3. /usr/lib/php

3.wget http://pecl.php.net/get/ssh2-0.12.tgz
Código BASH:
Ver original
  1. [root@Montes php]# wget http://pecl.php.net/get/ssh2-0.12.tgz
  2. --2013-08-07 14:54:38--  http://pecl.php.net/get/ssh2-0.12.tgz
  3. Resolviendo pecl.php.net... 76.75.200.106
  4. Connecting to pecl.php.net|76.75.200.106|:80... conectado.
  5. Petición HTTP enviada, esperando respuesta... 200 OK
  6. Longitud: 26223 (26K) [application/octet-stream]
  7. Saving to: `ssh2-0.12.tgz'
  8.  
  9. 100%[======================================>] 26.223      56,2K/s   in 0,5s    
  10.  
  11. 2013-08-07 14:54:39 (56,2 KB/s) - `ssh2-0.12.tgz' saved [26223/26223]

4. crar direcotorio build-dir
Código BASH:
Ver original
  1. [root@Montes php]# mkdir build-dir
  2. [root@Montes php]# ls -l
  3. total 36
  4. drwxr-xr-x. 2 root root  4096 ago  7 14:57 build-dir
  5. drwxrwxrwx. 2 root root  4096 ago  7 00:16 modules
  6. -rw-r--r--. 1 root root 26223 oct 15  2012 ssh2-0.12.tgz

5. mover y descomplirmir
Código BASH:
Ver original
  1. [root@Montes php]# mv ssh2-0.12.tgz build-dir
  2. [root@Montes php]# cd build-dir
  3. [root@Montes build-dir]# tar xzvf ssh2-0.12.tgz
  4. package.xml
  5. ssh2-0.12/config.m4
  6. ssh2-0.12/ssh2.c
  7. ssh2-0.12/php_ssh2.h
  8. ssh2-0.12/ssh2_fopen_wrappers.c
  9. ssh2-0.12/ssh2_sftp.c
  10. ssh2-0.12/LICENSE

5.compilar
Código BASH:
Ver original
  1. [root@Montes build-dir]# phpize
  2. Can't find PHP headers in /usr/include/php
  3. The php-devel package is required for use of this command.

es aca donde tengo el problema, que estoy haciendo mal?
  #9 (permalink)  
Antiguo 07/08/2013, 15:50
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: Error instalando extensión ssh2 PHP en Centos 6

hola amigos desistale todo el php que tenia

y seguir el tutorial que me recomendo triby http://safesrv.net/global-system-mod...ling-php-ssh2/ ya que el que me recomendo Carlangueitor no funciono

en phpinfo

observo que esta la extension ssh2
Cita:
ssh2
SSH2 support enabled
extension version 0.12
libssh2 version 1.4.2
banner SSH-2.0-libssh2_1.4.2
por comando
Código BASH:
Ver original
  1. [root@Montes ~]# php -m | grep ssh2
  2. ssh2

tambien lo comprobe por codigo php
Código PHP:
Ver original 

y obtengo
Cita:
bool(true)
pero voy a ejecutar el codigo http://localhost/ssh/index.php

y este es mi error
Cita:
Fatal error: Call to undefined function ssh2_conect() in

Etiquetas: php, ssh
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:45.