Jump to content

Why doesn't this work? (SSH2)


ChrisMartino

Recommended Posts

This is my script:

 

<?php
$connection = ssh2_connect('213.251.167.109', 22);
ssh2_auth_password($connection, 'root', 'MGdgfskc');

$stream = ssh2_exec($connection, 'useradd -d /home/users/test -m testftp');
$stream = ssh2_exec($connection, 'passwd testftp');
$stream = ssh2_exec($connection, 'password');
$stream = ssh2_exec($connection, 'password');
?>

 

This is my errors:

Fatal error: Call to undefined function ssh2_connect() in /home/chaosnz/public_html/fotosnap.net/test.php on line 2

 

Link to comment
https://forums.phpfreaks.com/topic/179584-why-doesnt-this-work-ssh2/
Share on other sites

Well, if the function doesn't exist then obviously the extension is not installed. How did you verify that it's installed? Check the output of phpinfo(). It'll give you info about your PHP environment.

 

Also try to run

<?php
var_dump(extension_loaded('ssh2'));

 

If that doesn't output true then it is not installed.

 

See get_loaded_extensions as well.

this is my features of my web hosting package:

 

Shell Access (SSH)

PHP 5.2.10 & Zend Optimizer

SQL Databases: MySQL 5.0.x & PostgreSQL 8.4.x

Ruby on Rails 2.3.x

Version Control: CVS, Subversion, Git (over SSH), and Mercurial

  • 1 month later...

This is my script:

 

<?php
$connection = ssh2_connect('213.251.167.109', 22);
ssh2_auth_password($connection, 'root', 'MGdgfskc');

$stream = ssh2_exec($connection, 'useradd -d /home/users/test -m testftp');
$stream = ssh2_exec($connection, 'passwd testftp');
$stream = ssh2_exec($connection, 'password');
$stream = ssh2_exec($connection, 'password');
?>

 

This is my errors:

Fatal error: Call to undefined function ssh2_connect() in /home/chaosnz/public_html/fotosnap.net/test.php on line 2

I was having this very problem but gave up and just wound up utilizing a pure-PHP implementation of SSH - phpSecLib:

 

http://phpseclib.sourceforge.net/

 

Even if you can get the ssh2 extension compiled you'll still have problems with ssh2_exec returning prematurely.  phpSecLib, in contrast, works perfectly.  It requires zero effort to get working and it works every time, too.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.