PHP7.3 - Can't get ssh2_connect working


This is my first time here and I could not find anything referencing this, so any help is appreciated. Keep im mind I am about 30 days in with EB so I am still a novice, but I do understand the basics and have loaded and ran a handful of sites already.

I noticed EB upgraded to 7.3 which is great news, but now I cannot get my application to recognize the ssh2_connect() function.

Currently I am adding this into my extensions:

  "/etc/php.d/ssh2.ini" :
    mode: "000755"
    owner: root
    group: root
    content: |

Which, this seems to add it correctly since the php.ini shows it in there. I have also rebooted the instance. Still, anytime I attempt to use our SSH2 functionality we get:

"Error: Call to undefined function ********ssh2_connect() in ********.php on line 157"

When checking PHP version here is my CLI notice:

[ec2-user@ip-*********** php.d]$ php -v
PHP Warning:  PHP Startup: Unable to load dynamic library '' (tried: /usr/lib64/php/7.3/modules/ (/usr/lib64/php/7.3/modules/ cannot open shared object file: No such file or directory), /usr/lib64/php/7.3/modules/ (/usr/lib64/php/7.3/modules/ cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.3.11 (cli) (built: Oct 31 2019 18:30:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.11, Copyright (c) 1999-2018, by Zend Technologies

From this it seems like the file does not exist, but the phpinfo() says it does. So... should I attempt to manually install libssh2? Is there a way to install it on the fly with EB configs?

Any help or insight would be appreciated!

asked 4 years ago2118 views
1 Answer

I found my own answer. It seems I was getting a false response from my php.ini regarding SSH2 being installed. Also, the SSH2 that it showed installed was also not compatible with PHP7.3. I terminated the EB instance and started a fresh one, then I was able to see that SSH2 was not installed at all. Below is the basic process to get SSH2 on PHP 7.3 in case anyone needs:

Check if installed:

php -r "print_r(get_loaded_extensions());"

Install libssh2-devel first:

sudo yum install libssh2-devel

Get PHP7.3 compatible version:


Unpack and build:

tar -xzvf ssh2-1.2.tgz
cd ssh2-1.2
make install

Verify installed now:

php -r "print_r(get_loaded_extensions());"
answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions