简体   繁体   中英

PHP sftp + fopen compared to ssh2_scp_send

I wanted to if there is any real difference using PHP sftp for file open like shown here and with ssh2_scp_send I am planning on uploading multiple files per php session and want to not spend to much time in uploading the files. If anyone is aware on how these to functions are implemented in PHP it would be great to know so i can choose the right one.

Thanks Again.

The SFTP and the SCP are different protocols. Both run over the SSH though.

The SCP can only copy (upload/download) files. It cannot do any other operation like listing directory contents, deleting files etc.

The SFTP is a full-fledged remote fie system protocol.

The SCP might be quicker in general, as it is better able to utilize the SSH virtual connection channel. But it's worth testing both.

Also note that the SCP will generally work against *nix SSH servers only. The SFTP is more universal.

For details on The SFTP + SCP refer to:
https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol
https://en.wikipedia.org/wiki/Secure_copy_protocol

ssh2_sftp() is used on a existing connection, then you use fopen() however, this is also considered 'insecure' by most. Which is where ssh2_scp_recv() uses the Secure Copy based on BSD RCP Protocol. SCP uses Secure Shell (SSH) for data transfer and uses the same mechanisms for authentication, thereby ensuring the authenticity and confidentiality of the data in transit. A client can send (upload) files to a server, optionally including their basic attributes (permissions, timestamps). Clients can also request files or directories from a server (download). SCP runs over TCP port 22 by default. Like RCP, there is no RFC that defines the specifics of the protocol.

http://www.php.net/manual/en/function.ssh2-scp-recv.php

http://en.wikipedia.org/wiki/Secure_copy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM