• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

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