Home  >  Article  >  Backend Development  >  Detailed explanation of ssh2 extension installation in php_PHP tutorial

Detailed explanation of ssh2 extension installation in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:40:28956browse

1. There are three servers with three different operating systems: 10.1, 10.2 and 11.2. I found that 11.2 does not need to be installed and already has some extensions. If you don't have it installed, it may be easy to install it through yast.

Tested on the 10.1 server. Because libssh needs to be installed before installing ssh2-0.11.0.tgz, so download it from the official website. Downloaded more than N versions. Neither works. All errors occurred during make.

I don’t even want to find out the reason, because this situation may be multifaceted.

I changed the server again to 10.2, and when I tried libssh2-0.18, it actually succeeded.

Okay, next, you should compile ssh2-0.11.0.tgz, haha, it went relatively smoothly. It actually worked.

Now, record your operation process so that you don’t forget it later and you can read this document again. hehe.

Requires two packages:

ssh2-0.11.0.tgz Download address: http://pecl.php.net/package/ssh2

libssh2-0.18.tar.gz Download address: http://sourceforge.net/projects/libssh2/files/

Install first, libssh2-0.18.tar.gz

Simple steps:

tar zxvf libssh2-0.18.tar.gz

cd libssh2-0.18

./configure

make && make install

Just wait for a while.

If nothing unexpected happens, it should be successful.

Next, install ssh2-0.11.0.tgz

tar zxvf ssh2-0.11.0.tgz

cd ssh2-0.11.0

phpize
./configure --with-ssh2
make
After completion, the ssh2.so file you need will be generated in the modules directory in the current directory

Configure it below to let apache recognize it.

Just copy this to the location of your .so file. However, please note that the location where the so file is stored is slightly different in different versions.

Mine is the default path:

/usr/lib/php5/extensions/

cp ssh2.so /usr/lib/php5/extensions/

One more thing is to add a configuration file,

Copy an ssh2.ini file in the /etc/php5/conf.d/ directory

cp mysql.ini ssh2.ini

Edit ssh2.ini and modify the content to:

extension=ssh2.so

OK, now restart apapche

apache2ctl -k restart

Use this command php -i|grep ssh2

As expected, you will see relevant information

/etc/php5/conf.d/ssh2.ini,
Registered PHP Streams => php, file, data, http, ftp, https, ftps, ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp, zip, compress.zlib
ssh2
libssh2 version => 0.18
banner => SSH-2.0-libssh2_0.18
PWD => ; /srv/www/vwokan/wokan2.0/ssh2-0.11.0
_SERVER["PWD"] => /srv/www/vwokan/wokan2.0/ssh2-0.11.0

Haha, this message means it has been successful.

The next step is to use php to execute the ssh2 extension command.

$connection = ssh2_connect("172.16.18.252",22);
if (ssh2_auth_password($connection,"root","123456")) {
echo "Authentication Successful! ";
} else {
die(Authentication Failed...);
}

?>

As expected, you will see the "Authentication Successful" message.

Haha, I just showed up. Unexpectedly, I checked. Every time the following prompt appears:

Authentication Failed...

The username and password are correct.

Finally, check the local ssh configuration

vi /etc/ssh/sshd_config

Found on:

PasswordAuthentication no

Haha, modified to:

PasswordAuthentication yes

Save and restart ssh

/etc/init.d/sshd restart

Haha, it actually passed.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486196.htmlTechArticle1. There are three servers, the operating systems are: 10.1 10.2 11.2 three different versions, found that 11.2 does not need to be installed , already has some extensions. If you don’t have it installed, it may be very convenient to pass...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn