From dafbdbf4d29e5cf84b3f4f2e38384df3d5060e6f Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 29 Feb 2012 16:53:07 -0500 Subject: [PATCH] Started SSH class for tunneled connections --- README.md | 1 + sys/common/ssh.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 sys/common/ssh.php diff --git a/README.md b/README.md index 2505e79..1c7f358 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Because php-gtk is such a pain to compile on Windows, I've put together this pac * php5-mysql * php5-postgresql * php5-sqlite + * php5-ssh2 * Run via terminal in the OpenSQLManager folder using `php index.php` ## PHP Requirements diff --git a/sys/common/ssh.php b/sys/common/ssh.php new file mode 100644 index 0000000..99418af --- /dev/null +++ b/sys/common/ssh.php @@ -0,0 +1,60 @@ +session =& ssh2_connect($host, $port); + + if($this->session === FALSE) + { + return FALSE; + } + + return $this; + } + + /** + * Create a tunnel using the current ssh connection + * + * @param string $host + * @param int $port + * @param string $auth_type + * @param array $auth_params + * @return stream + */ + public function tunnel($host, $port, $auth_type='password', $auth_params) + { + if($auth_type === 'password') + { + ssh2_auth_password(&$this->session, $auth_params['user'], $auth_params['pass']); + } + + $this->stream =& ssh2_tunnel(&$this->session, $host, $port); + + return $this->stream; + } +} \ No newline at end of file