Revision: 59925
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 10, 2012 00:31 by ryantxr
Initial Code
class SshApi extends BaseObject{ public $session = null; public $authenticated = false; public function __construct(){ } public function connect($host){ $this->session = ssh2_connect($host); return $this->session; } public function pubkeyFile($sshUser, $sshPub, $sshPriv, $sshPass){ if ( ! $this->session ) return false; if ( empty($sshPass) ){ $b = ssh2_auth_pubkey_file( $this->session, $sshUser, $sshPub, $sshPriv); } else $b = ssh2_auth_pubkey_file( $this->session, $sshUser, $sshPub, $sshPriv, $sshPass); if ( $b ) $this->authenticated = true; return $b; } public function send($localfile, $remotefile, $perms=0660){ $this->debug(__METHOD__); if ( ! $this->session ) return false; $this->debug('Sending '. $localfile . ' to ' . $remotefile); $b = ssh2_scp_send($this->session, $localfile, $remotefile, $perms); return $b; } public function recv($remotefile , $localfile){ if ( ! $this->session ) return false; $b = ssh2_scp_recv($this->session , $remotefile , $localfile ); return $b; } public function exec($command){ if ( ! $this->session ) return false; $stream = ssh2_exec($this->session, $command); return $stream; } }
Initial URL
Initial Description
This SSH API is used to execute remote commands, send and receive files.
Initial Title
PHP SSH API class
Initial Tags
file, ssh
Initial Language
PHP