Connect SSH to PHP to ensure the security of transmitted data (1)_PHP Tutorial

WBOY
Release: 2016-07-15 13:24:00
Original
815 people have browsed it

SSH can transmit data through the technology of encrypting online packets; using SSH, all data transmitted can be encrypted. Even if someone intercepts the data, no useful information can be obtained. At the same time, the data is compressed, which greatly speeds up the transmission speed. In short, through the use of SSH, data transmission can be ensured to be relatively secure and efficient.

However, not everyone knows that PHP can connect to SSH and execute remote commands, but it is very useful. Since we can leverage PHP in so many different ways, it has a lot of setting options to control its behavior. The large set of optional parameters allows you to use PHP for many different purposes, but it also means that the combination of these parameters and server-side configuration can introduce some security issues. The author has been using SSH in a PHP CLI application. I used it from cronjobs, but it was not very simple at the beginning. It can be said that it was quite complicated. The manual on the safe use of Shell2 functions is not very practical. The author conducted many experiments before writing this small article today. I hope that after reading it, it can save you some time in configuring PHP.

In this article, the author needs to assume:

The operating system you are running is Debian/Ubuntu. If you are not running Debian/Ubuntu, you may need to replace the corresponding content of this article with the package manager provided by your Linux distribution.

You are running PHP5. If you are not running PHP5, you can use PHP4 instead.

You have a basic understanding of PHP and server administration.

You already have PHP installed.

Prerequisites

Installing the package

First, let’s install the following package:

sudo aptitude update
sudo aptitude install php5-dev php5-cli php-pear buid-essential
openssl-dev zlib1g-dev

The installation is complete and go to the next step.

Compile libssh2

After downloading Libssh2 from the sourceforge website, we need to compile it, but don’t worry, you just need to follow the following method:

cd /usr/src
wget

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446794.htmlTechArticleSSH can transmit data through the technology of encrypting online packets; using SSH, all data transmitted can be encrypted Encrypted, even if someone intercepts the data, no useful information can be obtained...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template