-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve #56 : Implemented async SSH driver
- Loading branch information
Showing
41 changed files
with
3,998 additions
and
10 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Kraken\SSH\Auth; | ||
|
||
use Kraken\SSH\SSH2AuthInterface; | ||
|
||
/** | ||
* Agent based SSH2 authentication | ||
*/ | ||
class SSH2Agent implements SSH2AuthInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $username; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param string $username The authentication username | ||
*/ | ||
public function __construct($username) | ||
{ | ||
$this->username = $username; | ||
} | ||
|
||
/** | ||
* @override | ||
* @inheritDoc | ||
*/ | ||
public function authenticate($conn) | ||
{ | ||
return @ssh2_auth_agent( | ||
$conn, | ||
$this->username | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
namespace Kraken\SSH\Auth; | ||
|
||
use Kraken\SSH\SSH2AuthInterface; | ||
|
||
/** | ||
* Host based SSH2 authentication. | ||
*/ | ||
class SSH2HostBasedFile implements SSH2AuthInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $username; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $hostname; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $publicKeyFile; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $privateKeyFile; | ||
|
||
/** | ||
* @var null|string | ||
*/ | ||
protected $passPhrase; | ||
|
||
/** | ||
* @var null|string | ||
*/ | ||
protected $localUsername; | ||
|
||
/** | ||
* @param string $username The authentication username | ||
* @param string $hostname The authentication hostname | ||
* @param string $publicKeyFile The path of the public key file | ||
* @param string $privateKeyFile The path of the private key file | ||
* @param string $passPhrase An optional pass phrase for the key | ||
* @param string $localUsername An optional local usernale. If omitted, the username will be used | ||
*/ | ||
public function __construct($username, $hostname, $publicKeyFile, $privateKeyFile, $passPhrase = null, $localUsername = null) | ||
{ | ||
$this->username = $username; | ||
$this->hostname = $hostname; | ||
$this->publicKeyFile = $publicKeyFile; | ||
$this->privateKeyFile = $privateKeyFile; | ||
$this->passPhrase = $passPhrase; | ||
$this->localUsername = $localUsername; | ||
} | ||
|
||
/** | ||
* @override | ||
* @inheritDoc | ||
*/ | ||
public function authenticate($conn) | ||
{ | ||
return @ssh2_auth_hostbased_file( | ||
$conn, | ||
$this->username, | ||
$this->hostname, | ||
$this->publicKeyFile, | ||
$this->privateKeyFile, | ||
$this->passPhrase, | ||
$this->localUsername | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Kraken\SSH\Auth; | ||
|
||
use Kraken\SSH\SSH2AuthInterface; | ||
|
||
/** | ||
* Username based SSH2 authentication. | ||
*/ | ||
class SSH2None implements SSH2AuthInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $username; | ||
|
||
/** | ||
* @param string $username The authentication username | ||
*/ | ||
public function __construct($username) | ||
{ | ||
$this->username = $username; | ||
} | ||
|
||
/** | ||
* @override | ||
* @inheritDoc | ||
*/ | ||
public function authenticate($conn) | ||
{ | ||
return true === @ssh2_auth_none($conn, $this->username); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Kraken\SSH\Auth; | ||
|
||
use Kraken\SSH\SSH2AuthInterface; | ||
|
||
/** | ||
* Password based SSH2 authentication | ||
*/ | ||
class SSH2Password implements SSH2AuthInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $username; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $password; | ||
|
||
/** | ||
* @param string $username The authentication username | ||
* @param string $password The authentication password | ||
*/ | ||
public function __construct($username, $password) | ||
{ | ||
$this->username = $username; | ||
$this->password = $password; | ||
} | ||
|
||
/** | ||
* @override | ||
* @inheritDoc | ||
*/ | ||
public function authenticate($conn) | ||
{ | ||
return @ssh2_auth_password($conn, $this->username, $this->password); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Kraken\SSH\Auth; | ||
|
||
use Kraken\SSH\SSH2AuthInterface; | ||
|
||
/** | ||
* Public key based SSH2 authentication | ||
*/ | ||
class SSH2PublicKeyFile implements SSH2AuthInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $username; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $publicKeyFile; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $privateKeyFile; | ||
|
||
/** | ||
* @var null|string | ||
*/ | ||
protected $passPhrase; | ||
|
||
/** | ||
* @param string $username The authentication username | ||
* @param string $publicKeyFile The path of the public key file | ||
* @param string $privateKeyFile The path of the private key file | ||
* @param string|null $passPhrase An optional pass phrase for the key | ||
*/ | ||
public function __construct($username, $publicKeyFile, $privateKeyFile, $passPhrase = null) | ||
{ | ||
$this->username = $username; | ||
$this->publicKeyFile = $publicKeyFile; | ||
$this->privateKeyFile = $privateKeyFile; | ||
$this->passPhrase = $passPhrase; | ||
} | ||
|
||
/** | ||
* @override | ||
* @inheritDoc | ||
*/ | ||
public function authenticate($conn) | ||
{ | ||
return @ssh2_auth_pubkey_file( | ||
$conn, | ||
$this->username, | ||
$this->publicKeyFile, | ||
$this->privateKeyFile, | ||
$this->passPhrase | ||
); | ||
} | ||
} |
Oops, something went wrong.