How to install ssh2 for php 7.3

10,940

Solution 1

Theres an existing report on bugs.php.net, where user goldorakhong commented to compile it from source.

Using a docker file this can be done so:

RUN cd /tmp \
    && git clone https://git.php.net/repository/pecl/networking/ssh2.git \
    && cd /tmp/ssh2/ \
    && .travis/build.sh \
    && docker-php-ext-enable ssh2

If your not using docker you'll need to substitute docker-php-ext-enable to register the variable somehow else.

Solution 2

Windows 2008 R2 64 bit

Wampserver 3.1.9 64 bit

PHP 7.3.12

1 - Download php_ssh2.dll and php_ssh2.pdb from https://windows.php.net/downloads/pecl/releases/ssh2/

2 - Select 9/18/2019 11:50 AM 1.2

3 - Select 9/18/2019 10:45 AM 438049 php_ssh2-1.2-7.3-ts-vc15-x64.zip

4 - Unzip and copy php_ssh2.dll and php_ssh2.pdb into C:/wamp64/bin/php/php7.3.12/ext/

5 - In php.ini insert line: extension=php_ssh2.dll

6 - In wamp restart all services

Share:
10,940
Marco
Author by

Marco

by day: full stack developer by night: managing groupware, blogging- and shopsystems on linux servers with docker for fun: arduino & IoT enthusiast, diy hardware projects

Updated on June 08, 2022

Comments

  • Marco
    Marco almost 2 years

    When trying to install the extension ssh2 via pecl, I encounter the below error messages. I was using a docker container based on php:7.3.2-fpm

    Steps to reproduce:

    • Install PHP 7.3.2
    • Install the packages libssh2-1-dev and libssh2-1
    • Try to install the ssh2 extension via pecl install ssh2-1.1.2

    So how can I successfully install the ssh2 extension?

    ...
    
    /tmp/pear/temp/ssh2/ssh2_fopen_wrappers.c: In function 'php_ssh2_fopen_wrapper_tunnel':
    /tmp/pear/temp/ssh2/ssh2_fopen_wrappers.c:1265:42: error: invalid operands to binary == (have 'zend_string {aka struct _zend_string}' and 'int')
      if (resource->path && resource->path[0] == '/') {
                            ~~~~~~~~~~~~~~~~~ ^~
    /tmp/pear/temp/ssh2/ssh2_fopen_wrappers.c:1268:8: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
       host = resource->path + 1;
            ^
    Makefile:196: recipe for target 'ssh2_fopen_wrappers.lo' failed
    make: *** [ssh2_fopen_wrappers.lo] Error 1
    ERROR: `make' failed
    

    I found this question unanswered and put on hold on superusers when I first googled for it. I think its more suited here.

  • Marco
    Marco over 4 years
    This is very opinionated but I recommend phpseclib over ssh2. It can be installed via composer. No need for PEAR or compiling. Also ssh2 constantly gave me segfaults and worse when using the ssh2.sftp://-wrapper.
  • JohnGalt
    JohnGalt about 4 years
    Why does the build.sh script in the .travis directory CREATE A NEW USER and give it ssh access on the server? That does not seem like a good idea, nor does it seem necessary. Is there any reasonable explanation for this?