Skip to content

Commit

Permalink
Throw exception if there is a connection error
Browse files Browse the repository at this point in the history
  • Loading branch information
DivineOmega committed Aug 7, 2019
1 parent 4501c7e commit 9956819
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/SSHConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public function connect(): self

$this->resource = ssh2_connect($this->hostname, $this->port);

if (!$this->resource) {
throw new RuntimeException('Error connecting to server.');
}

if ($this->publicKeyPath || $this->privateKeyPath) {
$authenticated = ssh2_auth_pubkey_file($this->resource, $this->username, $this->publicKeyPath, $this->privateKeyPath);
if (!$authenticated) {
Expand Down

0 comments on commit 9956819

Please sign in to comment.