Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ////////////////////////////
- // Made by Filipe Fernandes
- // v0.1
- ////////////////////////////
- class ssh2 {
- private $host = "host";
- private $user = "root";
- private $pass = "ehsegredonaodigasaninguem";
- Private $port = "22";
- var $conn;
- var $error;
- var $stream;
- function login() {
- if ($this->connect()) {
- if ($this->auth()) {return 1;}
- else {return 0;}
- }
- else {return 0;}
- }
- function connect() {
- if ($this->conn=ssh2_connet($this->host, $this->port)) { return 1; }
- else
- { echo "erro"; $this->error=" Cannot connect to host "; return 0; }
- }
- function auth() {
- if (@ssh2_auth_password($this->conn, $this->user, $this->pass)) {return 1;}
- else {$this->error="invalid login"; return 0; }
- }
- function cmd($cmd) {
- $this->stream=ssh2_exec($this->conn, $cmd);
- stream_set_blocking($this->stream, true);
- }
- function output() {
- while ($get=fgets($this->stream)) {
- $line.=$get;
- }
- return $line;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement