How to install ssh2 extension in php _ PHP Tutorial

Source: Internet
Author: User
For more information about ssh2 extension installation in php, see. 1. there are three servers in the operating system: 10.110.211.2 and three different versions. it is found that 11.2 does not need to be installed and has some extensions. If you haven't installed it, it may be very convenient. 1. there are three servers, the operating system is 10.1 10.2 11.2 11.2 three different versions, and it is found that does not need to be installed and has some extensions. If you have not installed yast, it is very convenient to install yast.

Test on the 10.1 server, because you need to install libssh before installing the ssh2-0.11.0.tgz, so go to the official website to download. N versions have been downloaded. None. Errors occur during make.

I don't want to find the reason, because this situation may be caused by many reasons.

Another server, 10.2, when the trial to libssh2-0.18 time, actually succeeded.

Okay, next, it should compile the ssh2-0.11.0.tgz, huh, it is relatively smooth. Actually succeeded.

Now, record your operation process so that you do not forget it. you can read this document again. Haha.

Two software packages are required:

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

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

First install libssh2-0.18.tar.gz

Simple steps:

Tar zxvf libssh2-0.18.tar.gz

Cd libssh2-0.18

./Configure

Make & make install

Wait for a while.

It should have been 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 that, the required ssh2.so file will be generated in the modules directory in the current directory.

The following configuration makes apache understand it.

Copy the file to your. so file. Note that the storage location of the so file varies depending on the version.

My default path is:

/Usr/lib/php5/extensions/

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

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:

Extension = ssh2.so

Now, restart apapche.

Apache2ctl-k restart

Run the php-I | grep ssh2 command.

No surprise, you will see the 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

This information indicates that the operation is successful.

Next, we will use php to execute the ssh2 extension command.

$ Connection = ssh2_connect ("172.16.18.252", 22 );
If (sssh2_auth_password ($ connection, "root", "123456 ")){
Echo "Authentication Successful! ";
} Else {
Die (Authentication Failed ...);
}

?>

You will see "Authentication Successful.

Well, I encountered it. in an accident, I checked it. The following prompt appears every time:

Authentication Failed...

There are no errors in user names and passwords.

Finally, check the local ssh configuration.

Vi/etc/ssh/sshd_config

Found in:

PasswordAuthentication no

Modified:

PasswordAuthentication yes

Save and restart ssh

/Etc/init. d/sshd restart

Haha, it actually passed.

In versions 10.2 and 11.2, it is found that 11.2 does not need to be installed and has some extensions. If you have not installed it, it may be very convenient...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.