Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • components
        • events
          • default
      • controllers
      • models
    • components
      • auth
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • exchange
        • rates
          • foxrate
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
      • json
      • modules
      • net
        • http
        • net
          • amazon
            • s3
          • geo
            • ip
      • plugins
      • recaptcha
      • security
      • session
        • cart
      • settingscollection
      • upgrades
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
  • com
    • tecnick
      • tcpdf
        • blesta
          • components
            • invoice
              • templates
                • quickbooks
                  • invoice
                • templates
                  • default
  • Crypt
    • AES
    • DES
    • Hash
    • Random
    • RC4
    • Rijndael
    • RSA
    • TerraDES
  • File
    • ANSI
    • ASN1
    • X509
  • Math
    • BigInteger
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • html
      • xml
    • lib
  • Net
    • SFTP
    • SSH1
    • SSH2
  • None
  • PHP
  • PHPMailer
  • Services
    • JSON
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Net_SSH2

Class Net_SSH2

Pure-PHP implementation of SSHv2.

Direct known subclasses

Net_SFTP

Package: Net\SSH2
Copyright: MMVII Jim Wigginton
License: MIT License
Author: Jim Wigginton <terrafrost@php.net>
Version: 0.1.0
Located at vendors/phpseclib/Net/SSH2.php

Methods summary

public Net_SSH2
# Net_SSH2( String $host, optional $port = 22, optional $timeout = 10 )

Default Constructor.

Default Constructor.

Connects to an SSHv2 server

Parameters

$host
String
$host
$port
optional
Integer $port
$timeout
optional
Integer $timeout

Returns

Net_SSH2
public
# _key_exchange( String $kexinit_payload_server )

Key Exchange

Key Exchange

Parameters

$kexinit_payload_server
String
$kexinit_payload_server
public Boolean
# login( String $username, optional $password = '' )

Login

Login

The $password parameter can be a plaintext password or a Crypt_RSA object.

Parameters

$username
String
$username
$password
optional
String $password

Returns

Boolean
public Boolean
# _keyboard_interactive_login( String $username, String $password )

Login via keyboard-interactive authentication

Login via keyboard-interactive authentication

See RFC4256 for details. This is not a full-featured keyboard-interactive authenticator.

Parameters

$username
String
$username
$password
String
$password

Returns

Boolean
public Boolean
# _keyboard_interactive_process( )

Handle the keyboard-interactive requests / responses.

Handle the keyboard-interactive requests / responses.

Returns

Boolean
public Boolean
# _privatekey_login( String $username, Crypt_RSA $privatekey )

Login with an RSA private key

Login with an RSA private key

Parameters

$username
String
$username
$privatekey
Crypt_RSA
$password

Returns

Boolean
public
# setTimeout( Mixed $timeout )

Set Timeout

Set Timeout

$ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout. Setting $timeout to false or 0 will mean there is no timeout.

Parameters

$timeout
Mixed
$timeout
public String
# exec( String $command, optional $block = true )

Execute Command

Execute Command

If $block is set to false then Net_SSH2::_get_channel_packet(NET_SSH2_CHANNEL_EXEC) will need to be called manually. In all likelihood, this is not a feature you want to be taking advantage of.

Parameters

$command
String
$command
$block
optional
Boolean $block

Returns

String
public Boolean
# _initShell( )

Creates an interactive shell

Creates an interactive shell

Returns

Boolean

See

Net_SSH2::read()
Net_SSH2::write()
public String
# read( String $expect = '', Integer $mode = NET_SSH2_READ_SIMPLE )

Returns the output of an interactive shell

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 == NET_SSH2_READ_REGEX, a regular expression.

Parameters

$expect
String
$expect
$mode
Integer
$mode

Returns

String

See

Net_SSH2::read()
public Boolean
# write( String $cmd )

Inputs a command into an interactive shell.

Inputs a command into an interactive shell.

Parameters

$cmd
String
$cmd

Returns

Boolean

See

Net_SSH1::interactiveWrite()
public
# disconnect( )

Disconnect

Disconnect

public
# __destruct( )

Destructor.

Destructor.

Will be called, automatically, if you're supporting just PHP5. If you're supporting PHP4, you'll need to call disconnect().

public String
# _get_binary_packet( )

Gets Binary Packets

Gets Binary Packets

See '6. Binary Packet Protocol' of rfc4253 for more info.

Returns

String

See

Net_SSH2::_send_binary_packet()
public String
# _filter( mixed $payload )

Filter Binary Packets

Filter Binary Packets

Because some binary packets need to be ignored...

Returns

String

See

Net_SSH2::_get_binary_packet()
public Mixed
# _get_channel_packet( mixed $client_channel, mixed $skip_extended = false )

Gets channel data

Gets channel data

Returns the data as a string if it's available and false if not.

Parameters

$client_channel
mixed
$client_channel
$skip_extended

Returns

Mixed
public Boolean
# _send_binary_packet( String $data )

Sends Binary Packets

Sends Binary Packets

See '6. Binary Packet Protocol' of rfc4253 for more info.

Parameters

$data
String
$data

Returns

Boolean

See

Net_SSH2::_get_binary_packet()
public
# _append_log( String $message_number, mixed $message )

Logs data packets

Logs data packets

Makes sure that only the last 1MB worth of packets will be logged

Parameters

$message_number
String
$data
$message
public Boolean
# _send_channel_packet( Integer $client_channel, String $data )

Sends channel data

Sends channel data

Spans multiple SSH_MSG_CHANNEL_DATAs if appropriate

Parameters

$client_channel
Integer
$client_channel
$data
String
$data

Returns

Boolean
public Boolean
# _close_channel( Integer $client_channel )

Closes and flushes a channel

Closes and flushes a channel

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.

Parameters

$client_channel
Integer
$client_channel

Returns

Boolean
public Boolean
# _disconnect( Integer $reason )

Disconnect

Disconnect

Parameters

$reason
Integer
$reason

Returns

Boolean
public String
# _string_shift( String & $string, optional $index = 1 )

String Shift

String Shift

Inspired by array_shift

Parameters

$string
String
$string
$index
optional
Integer $index

Returns

String
public
# _define_array( )

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.

public String
# getLog( )

Returns a log of the packets that have been sent and received.

Returns a log of the packets that have been sent and received.

Returns a string if NET_SSH2_LOGGING == NET_SSH2_LOG_COMPLEX, an array if NET_SSH2_LOGGING == NET_SSH2_LOG_SIMPLE and false if !defined('NET_SSH2_LOGGING')

Returns

String
or Array
public String
# _format_log( Array $message_log, Array $message_number_log )

Formats a log for printing

Formats a log for printing

Parameters

$message_log
Array
$message_log
$message_number_log
Array
$message_number_log

Returns

String
public String
# getErrors( )

Returns all errors

Returns all errors

Returns

String
public String
# getLastError( )

Returns the last error

Returns the last error

Returns

String
public String
# getServerIdentification( )

Return the server identification.

Return the server identification.

Returns

String
public Array
# getKexAlgorithms( )

Return a list of the key exchange algorithms the server supports.

Return a list of the key exchange algorithms the server supports.

Returns

Array
public Array
# getServerHostKeyAlgorithms( )

Return a list of the host key (public key) algorithms the server supports.

Return a list of the host key (public key) algorithms the server supports.

Returns

Array
public Array
# getEncryptionAlgorithmsClient2Server( )

Return a list of the (symmetric key) encryption algorithms the server supports, when receiving stuff from the client.

Return a list of the (symmetric key) encryption algorithms the server supports, when receiving stuff from the client.

Returns

Array
public Array
# getEncryptionAlgorithmsServer2Client( )

Return a list of the (symmetric key) encryption algorithms the server supports, when sending stuff to the client.

Return a list of the (symmetric key) encryption algorithms the server supports, when sending stuff to the client.

Returns

Array
public Array
# getMACAlgorithmsClient2Server( )

Return a list of the MAC algorithms the server supports, when receiving stuff from the client.

Return a list of the MAC algorithms the server supports, when receiving stuff from the client.

Returns

Array
public Array
# getMACAlgorithmsServer2Client( )

Return a list of the MAC algorithms the server supports, when sending stuff to the client.

Return a list of the MAC algorithms the server supports, when sending stuff to the client.

Returns

Array
public Array
# getCompressionAlgorithmsClient2Server( )

Return a list of the compression algorithms the server supports, when receiving stuff from the client.

Return a list of the compression algorithms the server supports, when receiving stuff from the client.

Returns

Array
public Array
# getCompressionAlgorithmsServer2Client( )

Return a list of the compression algorithms the server supports, when sending stuff to the client.

Return a list of the compression algorithms the server supports, when sending stuff to the client.

Returns

Array
public Array
# getLanguagesServer2Client( )

Return a list of the languages the server supports, when sending stuff to the client.

Return a list of the languages the server supports, when sending stuff to the client.

Returns

Array
public Array
# getLanguagesClient2Server( )

Return a list of the languages the server supports, when receiving stuff from the client.

Return a list of the languages the server supports, when receiving stuff from the client.

Returns

Array
public Mixed
# getServerPublicHostKey( )

Returns the server public host key.

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.

Returns

Mixed

Magic methods summary

Properties summary

public String $identifier
#

The SSH identifier

The SSH identifier

public Object $fsock
#

The Socket Object

The Socket Object

public Integer $bitmap
#

Execution Bitmap

Execution Bitmap

The bits that are set reprsent functions that have been called already. This is used to determine if a requisite function has been successfully executed. If not, an error should be thrown.

public String $errors
#

Error information

Error information

See

Net_SSH2::getErrors()
Net_SSH2::getLastError()
public String $server_identifier
#

Server Identifier

Server Identifier

See

Net_SSH2::getServerIdentification()
public Array $kex_algorithms
#

Key Exchange Algorithms

Key Exchange Algorithms

See

Net_SSH2::getKexAlgorithims()
public Array $server_host_key_algorithms
#

Server Host Key Algorithms

Server Host Key Algorithms

See

Net_SSH2::getServerHostKeyAlgorithms()
public Array $encryption_algorithms_client_to_server
#

Encryption Algorithms: Client to Server

Encryption Algorithms: Client to Server

See

Net_SSH2::getEncryptionAlgorithmsClient2Server()
public Array $encryption_algorithms_server_to_client
#

Encryption Algorithms: Server to Client

Encryption Algorithms: Server to Client

See

Net_SSH2::getEncryptionAlgorithmsServer2Client()
public Array $mac_algorithms_client_to_server
#

MAC Algorithms: Client to Server

MAC Algorithms: Client to Server

See

Net_SSH2::getMACAlgorithmsClient2Server()
public Array $mac_algorithms_server_to_client
#

MAC Algorithms: Server to Client

MAC Algorithms: Server to Client

See

Net_SSH2::getMACAlgorithmsServer2Client()
public Array $compression_algorithms_client_to_server
#

Compression Algorithms: Client to Server

Compression Algorithms: Client to Server

See

Net_SSH2::getCompressionAlgorithmsClient2Server()
public Array $compression_algorithms_server_to_client
#

Compression Algorithms: Server to Client

Compression Algorithms: Server to Client

See

Net_SSH2::getCompressionAlgorithmsServer2Client()
public Array $languages_server_to_client
#

Languages: Server to Client

Languages: Server to Client

See

Net_SSH2::getLanguagesServer2Client()
public Array $languages_client_to_server
#

Languages: Client to Server

Languages: Client to Server

See

Net_SSH2::getLanguagesClient2Server()
public Integer $encrypt_block_size
#

Block Size for Server to Client Encryption

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

See

Net_SSH2::Net_SSH2()
Net_SSH2::_send_binary_packet()
public Integer $decrypt_block_size
#

Block Size for Client to Server Encryption

Block Size for Client to Server Encryption

See

Net_SSH2::Net_SSH2()
Net_SSH2::_get_binary_packet()
public Object $decrypt
#

Server to Client Encryption Object

Server to Client Encryption Object

See

Net_SSH2::_get_binary_packet()
public Object $encrypt
#

Client to Server Encryption Object

Client to Server Encryption Object

See

Net_SSH2::_send_binary_packet()
public Object $hmac_create
#

Client to Server HMAC Object

Client to Server HMAC Object

See

Net_SSH2::_send_binary_packet()
public Object $hmac_check
#

Server to Client HMAC Object

Server to Client HMAC Object

See

Net_SSH2::_get_binary_packet()
public Integer $hmac_size
#

Size of server to client HMAC

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.

See

Net_SSH2::_get_binary_packet()
public String $server_public_host_key
#

Server Public Host Key

Server Public Host Key

See

Net_SSH2::getServerPublicHostKey()
public String $session_id
#

Session identifer

Session identifer

"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

See

Net_SSH2::_key_exchange()
public String $exchange_hash
#

Exchange hash

Exchange hash

The current exchange hash

See

Net_SSH2::_key_exchange()
public Array $message_numbers
#

Message Numbers

Message Numbers

See

Net_SSH2::Net_SSH2()
public Array $disconnect_reasons
#

Disconnection Message 'reason codes' defined in RFC4253

Disconnection Message 'reason codes' defined in RFC4253

See

Net_SSH2::Net_SSH2()
public Array $channel_open_failure_reasons
#

SSH_MSG_CHANNEL_OPEN_FAILURE 'reason codes', defined in RFC4254

SSH_MSG_CHANNEL_OPEN_FAILURE 'reason codes', defined in RFC4254

See

Net_SSH2::Net_SSH2()
public Array $terminal_modes
#

Terminal Modes

Terminal Modes

See

Net_SSH2::Net_SSH2()

Link

http://tools.ietf.org/html/rfc4254#section-8
public Array $channel_extended_data_type_codes
#

SSH_MSG_CHANNEL_EXTENDED_DATA's data_type_codes

SSH_MSG_CHANNEL_EXTENDED_DATA's data_type_codes

See

Net_SSH2::Net_SSH2()

Link

http://tools.ietf.org/html/rfc4254#section-5.2
public Integer $send_seq_no
#

Send Sequence Number

Send Sequence Number

See 'Section 6.4. Data Integrity' of rfc4253 for more info.

See

Net_SSH2::_send_binary_packet()
public Integer $get_seq_no
#

Get Sequence Number

Get Sequence Number

See 'Section 6.4. Data Integrity' of rfc4253 for more info.

See

Net_SSH2::_get_binary_packet()
public Array $server_channels
#

Server Channels

Server Channels

Maps client channels to server channels

See

Net_SSH2::_get_channel_packet()
Net_SSH2::exec()
public Array $channel_buffers
#

Channel Buffers

Channel Buffers

If a client requests a packet from one channel but receives two packets from another those packets should be placed in a buffer

See

Net_SSH2::_get_channel_packet()
Net_SSH2::exec()
public Array $channel_status
#

Channel Status

Channel Status

Contains the type of the last sent message

See

Net_SSH2::_get_channel_packet()
public Array $packet_size_client_to_server
#

Packet Size

Packet Size

Maximum packet size indexed by channel

See

Net_SSH2::_send_channel_packet()
public Array $message_number_log
#

Message Number Log

Message Number Log

See

Net_SSH2::getLog()
public Array $message_log
#

Message Log

Message Log

See

Net_SSH2::getLog()
public Integer $window_size
#

The Window Size

The Window Size

Bytes the other party can send before it must wait for the window to be adjusted (0x7FFFFFFF = 4GB)

See

Net_SSH2::_send_channel_packet()
Net_SSH2::exec()
public Array $window_size_client_to_server
#

Window size

Window size

Window size indexed by channel

See

Net_SSH2::_send_channel_packet()
public String $signature
#

Server signature

Server signature

Verified against $this->session_id

See

Net_SSH2::getServerPublicHostKey()
public String $signature_format
#

Server signature format

Server signature format

ssh-rsa or ssh-dss.

See

Net_SSH2::getServerPublicHostKey()
public Array $interactiveBuffer
#

Interactive Buffer

Interactive Buffer

See

Net_SSH2::read()
public Integer $log_size
#

Current log size

Current log size

Should never exceed NET_SSH2_LOG_MAX_SIZE

See

Net_SSH2::_send_binary_packet()
Net_SSH2::_get_binary_packet()
public mixed $timeout
#

Timeout

Timeout

See

Net_SSH2::setTimeout()
public mixed $curTimeout
#

Current Timeout

Current Timeout

See

Net_SSH2::_get_channel_packet()
public mixed $realtime_log_file
#

Real-time log file pointer

Real-time log file pointer

See

Net_SSH2::_append_log()
public mixed $realtime_log_size
#

Real-time log file size

Real-time log file size

See

Net_SSH2::_append_log()
public boolean $signature_validated
#

Has the signature been validated?

Has the signature been validated?

See

Net_SSH2::getServerPublicHostKey()
public mixed $realtime_log_wrap
#

Real-time log file wrap boolean

Real-time log file wrap boolean

See

Net_SSH2::_append_log()
Blesta API documentation generated by ApiGen 2.8.0