• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion
  • Inviting everyone to the UX test of a new security feature in the WP Toolkit
    For WordPress site owners, threats posed by hackers are ever-present. Because of this, we are developing a new security feature for the WP Toolkit. If the topic of WordPress website security is relevant to you, we would be grateful if you could share your experience and help us test the usability of this feature. We invite you to join us for a 1-hour online session via Google Meet. Select a convenient meeting time with our friendly UX staff here.

Resolved How to install SSH2 extension for PHP 7.4.x with Ubuntu 20.4.1 LTS

Automata

Basic Pleskian
Hi,

Operating system:
Ubuntu 20.04.1 LTS

Plesk version:
Plesk Obsidian v18.0.29_build1800200731.19


I have already googled and tried all the existing guides but unfortunately none seem to work.

So i kindly ask for help on how to install SSH2 extension for PHP 7.4.x with Ubuntu 20.4.1 LTS on Plesk Obsidian v18.0.29_build1800200731.19

I would like to thank in advance anyone who wants or can help me now.
 
Last edited:
The ssh2 module compiling process for PHP 7.4 is not trivial. I compiled it on Ubuntu (I have no Debian server), but I think the compiling for Debian will take place in about the same way:

1. Install all necessary packages:

# apt-get install libssh2-1-dev libssh2-1 plesk-php74-dev make gcc

2. Download ssh2-php source:

# wget https://pecl.php.net/get/ssh2-1.2.tgz

3. Unarchive it:

# tar -xzf ssh2-1.2.tgz

4. Compile ssh2.so module:

# cd ssh2-1.2
# /opt/plesk/php/7.4/bin/phpize
# ./configure --with-php-config=/opt/plesk/php/7.4/bin/php-config
# make

5. Copy compiled module to appropriate directory:

# cd /root/ssh2-1.2/modules/
# cp ssh2.so /opt/plesk/php/7.4/lib/php/modules/

6. Create ini fire and re-read configs:

# echo "extension=ssh2.so" > /opt/plesk/php/7.4/etc/php.d/ssh2.ini
# plesk bin php_handler --reread

7. Check that ssh2 module is successfully loaded:

# /opt/plesk/php/7.4/bin/php -m | grep ssh2
ssh2
 
Hi dear "IgorG",

Your solution is perfect and works great !

Your help has been very valuable to me and i am sure that the solution you have found will be useful to many other Plesk users.

So i take this opportunity to thank you very much for your very fast, accurate and professional support, thanks again very much.

Can i ask you why on Plesk the SSH2 extension is not present by default and why don't add it ?

I greet you wishing you a good day and a good job.
 
The ssh2 module compiling process for PHP 7.4 is not trivial. I compiled it on Ubuntu (I have no Debian server), but I think the compiling for Debian will take place in about the same way:

1. Install all necessary packages:

# apt-get install libssh2-1-dev libssh2-1 plesk-php74-dev make gcc

2. Download ssh2-php source:

# wget https://pecl.php.net/get/ssh2-1.2.tgz

3. Unarchive it:

# tar -xzf ssh2-1.2.tgz

4. Compile ssh2.so module:

# cd ssh2-1.2
# /opt/plesk/php/7.4/bin/phpize
# ./configure --with-php-config=/opt/plesk/php/7.4/bin/php-config
# make

5. Copy compiled module to appropriate directory:

# cd /root/ssh2-1.2/modules/
# cp ssh2.so /opt/plesk/php/7.4/lib/php/modules/

6. Create ini fire and re-read configs:

# echo "extension=ssh2.so" > /opt/plesk/php/7.4/etc/php.d/ssh2.ini
# plesk bin php_handler --reread

7. Check that ssh2 module is successfully loaded:

# /opt/plesk/php/7.4/bin/php -m | grep ssh2
ssh2
Igor - you are so the man. Thank you so much...
 
Hello,

I solicit your help for a ssh2 installation.
I use php 8.1.
I have an error at these steps:

root@ns380608:~/ssh2-1.2# make
/bin/bash /root/ssh2-1.2/libtool --mode=compile cc -I. -I/root/ssh2-1.2 -I/root/ssh2-1.2/include -I/root/ssh2-1.2/main -I/root/ssh2-1.2 -I/opt/plesk/php/8.1/include/php -I/opt/plesk/php/8.1/include/php/main -I/opt/plesk/php/8.1/include/php/TSRM -I/opt/plesk/php/8.1/include/php/Zend -I/opt/plesk/php/8.1/include/php/ext -I/opt/plesk/php/8.1/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -DZEND_COMPILE_DL_EXT=1 -c /root/ssh2-1.2/ssh2.c -o ssh2.lo -MMD -MF ssh2.dep -MT ssh2.lo
libtool: compile: cc -I. -I/root/ssh2-1.2 -I/root/ssh2-1.2/include -I/root/ssh2-1.2/main -I/root/ssh2-1.2 -I/opt/plesk/php/8.1/include/php -I/opt/plesk/php/8.1/include/php/main -I/opt/plesk/php/8.1/include/php/TSRM -I/opt/plesk/php/8.1/include/php/Zend -I/opt/plesk/php/8.1/include/php/ext -I/opt/plesk/php/8.1/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -DZEND_COMPILE_DL_EXT=1 -c /root/ssh2-1.2/ssh2.c -MMD -MF ssh2.dep -MT ssh2.lo -fPIC -DPIC -o .libs/ssh2.o
/root/ssh2-1.2/ssh2.c:49:2: warning: implicit declaration of function ‘ZEND_ARG_PASS_INFO’; did you mean ‘ZEND_ARG_OBJ_INFO’? [-Wimplicit-function-declaration]
49 | ZEND_ARG_PASS_INFO(1)
| ^~~~~~~~~~~~~~~~~~
| ZEND_ARG_OBJ_INFO
/root/ssh2-1.2/ssh2.c:49:2: warning: initialization of ‘const char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
/root/ssh2-1.2/ssh2.c:49:2: note: (near initialization for ‘php_ssh2_first_arg_force_ref[1].name’)
/root/ssh2-1.2/ssh2.c:49:2: error: initializer element is not constant
/root/ssh2-1.2/ssh2.c:49:2: note: (near initialization for ‘php_ssh2_first_arg_force_ref[1].name’)
/root/ssh2-1.2/ssh2.c: In function ‘php_ssh2_debug_cb’:
/root/ssh2-1.2/ssh2.c:103:17: warning: implicit declaration of function ‘call_user_function_ex’; did you mean ‘call_user_function’? [-Wimplicit-function-declaration]
103 | if (FAILURE == call_user_function_ex(NULL, NULL, data->disconnect_cb, NULL, 3, args, 0, NULL)) {
| ^~~~~~~~~~~~~~~~~~~~~
| call_user_function
/root/ssh2-1.2/ssh2.c: In function ‘zif_ssh2_disconnect’:
/root/ssh2-1.2/ssh2.c:443:6: error: void value not ignored as it ought to be
443 | if (zend_list_close(Z_RES_P(zsession)) != SUCCESS) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/ssh2-1.2/ssh2.c:443:41: error: invalid operands to binary != (have ‘const zend_internal_arg_info[1]’ {aka ‘const struct _zend_internal_arg_info[1]’} and ‘int’)
443 | if (zend_list_close(Z_RES_P(zsession)) != SUCCESS) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~
| |
| void
make: *** [Makefile:209: ssh2.lo] Error 1


5. Copy compiled module to appropriate directory:

# cd /root/ssh2-1.2/modules/
# cp ssh2.so /opt/plesk/php/7.4/lib/php/modules/

I don't have a ssh2.so file.

Do you have a solution?

Excuse my english, I'm french !
Thanks !
 
Back
Top