ChrisMartino Posted October 30, 2009 Share Posted October 30, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/179584-why-doesnt-this-work-ssh2/ Share on other sites More sharing options...
Psycho Posted October 30, 2009 Share Posted October 30, 2009 Do you have the PECL extension installed? http://www.php.net/manual/en/ssh2.installation.php Quote Link to comment https://forums.phpfreaks.com/topic/179584-why-doesnt-this-work-ssh2/#findComment-947616 Share on other sites More sharing options...
ChrisMartino Posted October 30, 2009 Author Share Posted October 30, 2009 Yep its installed, I use A2Hosting they have the ssh2 installed. Quote Link to comment https://forums.phpfreaks.com/topic/179584-why-doesnt-this-work-ssh2/#findComment-947622 Share on other sites More sharing options...
Daniel0 Posted October 30, 2009 Share Posted October 30, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/179584-why-doesnt-this-work-ssh2/#findComment-947660 Share on other sites More sharing options...
ChrisMartino Posted October 31, 2009 Author Share Posted October 31, 2009 this is it http://dino-host.net/info.php is it installed?. Quote Link to comment https://forums.phpfreaks.com/topic/179584-why-doesnt-this-work-ssh2/#findComment-948210 Share on other sites More sharing options...
ChrisMartino Posted October 31, 2009 Author Share Posted October 31, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/179584-why-doesnt-this-work-ssh2/#findComment-948225 Share on other sites More sharing options...
Daniel0 Posted October 31, 2009 Share Posted October 31, 2009 No, it is not installed. Having shell access, and having the PHP ssh2 extension installed is not the same thing. Quote Link to comment https://forums.phpfreaks.com/topic/179584-why-doesnt-this-work-ssh2/#findComment-948244 Share on other sites More sharing options...
banksreach Posted December 19, 2009 Share Posted December 19, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/179584-why-doesnt-this-work-ssh2/#findComment-980374 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.