Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCrankHank committed Oct 1, 2019
1 parent 312a07e commit 849761a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Adapters/SshAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ class SshAdapter implements AdapterInterface
/**
* SshAdapter constructor.
*
* @throws PublicKeyMismatchException
*
* @param $host
* @param $username
* @param $publicKey
Expand All @@ -66,10 +64,6 @@ public function __construct($host, $username, $publicKey)
{
$this->connection = new SSH2($host);

if ($this->connection->getServerPublicHostKey() !== $publicKey) {
throw new PublicKeyMismatchException('Public key mismatch');
}

$this->username = $username;

$this->publicKey = $publicKey;
Expand Down Expand Up @@ -99,22 +93,32 @@ public function getServerPublicHostKey()
* Login via password.
*
* @throws ConnectionNotPossibleException
* @throws PublicKeyMismatchException
* @param $password
*/
public function loginPassword($password)
{
if ($this->getServerPublicHostKey() !== $this->publicKey) {
throw new PublicKeyMismatchException('Public key mismatch');
}

$this->login($password);
}

/**
* Login via private key.
*
* @throws ConnectionNotPossibleException
* @throws PublicKeyMismatchException
* @param $key
* @param null $password
*/
public function loginKey($key, $password = null)
{
if ($this->getServerPublicHostKey() !== $this->publicKey) {
throw new PublicKeyMismatchException('Public key mismatch');
}

$crypt = new RSA;

if (! is_null($password)) {
Expand Down

0 comments on commit 849761a

Please sign in to comment.