PHP ssh2 Function Learning

Source: Internet
Author: User
Tags scp command

SSH2 is a module in PHP, it is to log on to the remote host to operate

But now about its Chinese text is very little, can only understand a little, record a little, and gradually improve

Ssh2_connect ($host, $port);

Ssh2_auth_password ($resource, $user, $password); Password Authentication method

Ssh2_sftp ($resource); Generate SFTP Handle

Ssh2_scp_send (); Similar to SCP command

Ssh2_exec ($resource, $cmd); Execute command

Ssh2_sftp_stat ($resource _sftp, $dir); View Catalog

Ssh2_sftp_mkdir ($resoruce _sftp, $dir); Create a Directory

There are some connetc handles, and some are SFTP handles,

Ssh2_exec () has a return value, and its return value is unformatted (no wrapping), but it is returned as a stream (stream).

Displayed, this can be streamed:

Stream_set_blocking ($stream, true);

Echo:stream_get_contents ($stream);

Using PHP to login to SSH remote host, rather than using putty and other terminal commands flexible, so encapsulated some functions used for common operations, such as:

Ssh_sftp_mkdir () et cetera

PHP ssh2 Function Learning

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.