MASK_CONSTRUCTOR
MASK_CONSTRUCTOR
Pure-PHP implementation of SSHv2.
$encrypt_block_size : integer
Block Size for Server to Client Encryption
"Note that the length of the concatenation of 'packet_length', 'padding_length', 'payload', and 'random padding' MUST be a multiple of the cipher block size or 8, whichever is larger. This constraint MUST be enforced, even when using stream ciphers."
-- http://tools.ietf.org/html/rfc4253#section-6
$hmac_size : integer
Size of server to client HMAC
We need to know how big the HMAC will be for the server to client direction so that we know how many bytes to read. For the client to server side, the HMAC object will make the HMAC as long as it needs to be. All we need to do is append it.
$session_id : string
Session identifier
"The exchange hash H from the first key exchange is additionally used as the session identifier, which is a unique identifier for this connection."
-- http://tools.ietf.org/html/rfc4253#section-7.2
__construct(mixed $host, integer $port = 22, integer $timeout = 10) : \phpseclib\Net\SSH2
Default Constructor.
$host can either be a string, representing the host, or a stream resource.
mixed | $host | |
integer | $port | |
integer | $timeout |
sendIdentificationStringFirst()
Send Identification String First
https://tools.ietf.org/html/rfc4253#section-4.2 says "when the connection has been established, both sides MUST send an identification string". It does not say which side sends it first. In theory it shouldn't matter but it is a fact of life that some SSH servers are simply buggy
sendIdentificationStringLast()
Send Identification String Last
https://tools.ietf.org/html/rfc4253#section-4.2 says "when the connection has been established, both sides MUST send an identification string". It does not say which side sends it first. In theory it shouldn't matter but it is a fact of life that some SSH servers are simply buggy
sendKEXINITFirst()
Send SSH_MSG_KEXINIT First
https://tools.ietf.org/html/rfc4253#section-7.1 says "key exchange begins by each sending sending the [SSH_MSG_KEXINIT] packet". It does not say which side sends it first. In theory it shouldn't matter but it is a fact of life that some SSH servers are simply buggy
sendKEXINITLast()
Send SSH_MSG_KEXINIT Last
https://tools.ietf.org/html/rfc4253#section-7.1 says "key exchange begins by each sending sending the [SSH_MSG_KEXINIT] packet". It does not say which side sends it first. In theory it shouldn't matter but it is a fact of life that some SSH servers are simply buggy
_encryption_algorithm_to_key_size(string $algorithm) : integer|null
Maps an encryption algorithm name to the number of key bytes.
string | $algorithm | Name of the encryption algorithm |
Number of bytes as an integer or null for unknown
_encryption_algorithm_to_crypt_instance(string $algorithm) : mixed
Maps an encryption algorithm name to an instance of a subclass of \phpseclib\Crypt\Base.
string | $algorithm | Name of the encryption algorithm |
Instance of \phpseclib\Crypt\Base or null for unknown
_keyboard_interactive_login(string $username, string $password) : boolean
Login via keyboard-interactive authentication
See RFC4256 for details. This is not a full-featured keyboard-interactive authenticator.
string | $username | |
string | $password |
_ssh_agent_login(string $username, \phpseclib\System\SSH\Agent $agent) : boolean
Login with an ssh-agent provided key
string | $username | |
\phpseclib\System\SSH\Agent | $agent |
exec(string $command, Callback $callback = null) : string
Execute Command
If $callback is set to false then \phpseclib\Net\SSH2::_get_channel_packet(self::CHANNEL_EXEC) will need to be called manually. In all likelihood, this is not a feature you want to be taking advantage of.
string | $command | |
Callback | $callback |
read(string $expect = '', integer $mode = self::READ_SIMPLE) : string
Returns the output of an interactive shell
Returns when there's a match for $expect, which can take the form of a string literal or, if $mode == self::READ_REGEX, a regular expression.
string | $expect | |
integer | $mode |
startSubsystem(string $subsystem) : boolean
Start a subsystem.
Right now only one subsystem at a time is supported. To support multiple subsystem's stopSubsystem() could accept a string that contained the name of the subsystem, but at that point, only one subsystem of each type could be opened. To support multiple subsystem's of the same name maybe it'd be best if startSubsystem() generated a new channel id and returns that and then that that was passed into stopSubsystem() but that'll be saved for a future date and implemented if there's sufficient demand for such a feature.
string | $subsystem |
ping() : boolean
Pings a server connection, or tries to reconnect if the connection has gone down
Inspired by http://php.net/manual/en/mysqli.ping.php
_close_channel(integer $client_channel, boolean $want_reply = false) : boolean
Closes and flushes a channel
\phpseclib\Net\SSH2 doesn't properly close most channels. For exec() channels are normally closed by the server and for SFTP channels are presumably closed when the client disconnects. This functions is intended for SCP more than anything.
integer | $client_channel | |
boolean | $want_reply |
_define_array()
Define Array
Takes any number of arrays whose indices are integers and whose values are strings and defines a bunch of named constants from it, using the value as the name of the constant and the index as the value of the constant. If any of the constants that would be defined already exists, none of the constants will be defined.
_array_intersect_first(array $array1, array $array2) : mixed
Returns the first value of the intersection of two arrays or false if the intersection is empty. The order is defined by the first parameter.
array | $array1 | |
array | $array2 |
False if intersection is empty, else intersected value.
getServerPublicHostKey() : mixed
Returns the server public host key.
Caching this the first time you connect to a server and checking the result on subsequent connections is recommended. Returns false if the server signature is not signed correctly with the public host key.