SCP
in package
Pure-PHP implementations of SCP.
Tags
Table of Contents
- MODE_SSH1 = 1
- SSH1 is being used.
- MODE_SSH2 = 2
- SSH2 is being used.
- SOURCE_LOCAL_FILE = 1
- Reads data from a local file.
- SOURCE_STRING = 2
- Reads data from a string.
- $mode : int
- Mode
- $packet_size : int
- Packet Size
- $ssh : object
- SSH Object
- __construct() : SCP
- Default Constructor.
- _close() : mixed
- Closes the connection to an SSH server
- _receive() : string
- Receives a packet from an SSH server
- _send() : mixed
- Sends a packet to an SSH server
- get() : mixed
- Downloads a file from the SCP server.
- put() : bool
- Uploads a file to the SCP server.
Constants
MODE_SSH1
SSH1 is being used.
public
mixed
MODE_SSH1
= 1
MODE_SSH2
SSH2 is being used.
public
mixed
MODE_SSH2
= 2
SOURCE_LOCAL_FILE
Reads data from a local file.
public
mixed
SOURCE_LOCAL_FILE
= 1
SOURCE_STRING
Reads data from a string.
public
mixed
SOURCE_STRING
= 2
Properties
$mode
Mode
public
int
$mode
Tags
$packet_size
Packet Size
public
int
$packet_size
Tags
$ssh
SSH Object
public
object
$ssh
Tags
Methods
__construct()
Default Constructor.
public
__construct(SSH1|SSH2 $ssh) : SCP
Connects to an SSH server
Parameters
Tags
Return values
SCP —_close()
Closes the connection to an SSH server
public
_close() : mixed
Tags
Return values
mixed —_receive()
Receives a packet from an SSH server
public
_receive() : string
Tags
Return values
string —_send()
Sends a packet to an SSH server
public
_send(string $data) : mixed
Parameters
- $data : string
Tags
Return values
mixed —get()
Downloads a file from the SCP server.
public
get(string $remote_file[, string $local_file = false ]) : mixed
Returns a string containing the contents of $remote_file if $local_file is left undefined or a boolean false if the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the operation
Parameters
- $remote_file : string
- $local_file : string = false
Tags
Return values
mixed —put()
Uploads a file to the SCP server.
public
put(string $remote_file, string $data[, int $mode = self::SOURCE_STRING ][, callable $callback = null ]) : bool
By default, \phpseclib\Net\SCP::put() does not read from the local filesystem. $data is dumped directly into $remote_file. So, for example, if you set $data to 'filename.ext' and then do \phpseclib\Net\SCP::get(), you will get a file, twelve bytes long, containing 'filename.ext' as its contents.
Setting $mode to self::SOURCE_LOCAL_FILE will change the above behavior. With self::SOURCE_LOCAL_FILE, $remote_file will contain as many bytes as filename.ext does on your local filesystem. If your filename.ext is 1MB then that is how large $remote_file will be, as well.
Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take care of that, yourself.
Parameters
- $remote_file : string
- $data : string
- $mode : int = self::SOURCE_STRING
- $callback : callable = null