Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Commit

Permalink
Added fallback for $HOME/keys/
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrizio Branca committed Feb 10, 2017
1 parent c49ee00 commit b25247c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/AwsInspector/Model/Ec2/Instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use AwsInspector\Helper\Curl;
use AwsInspector\Ssh\Connection;
use AwsInspector\Ssh\PrivateKey;
use Symfony\Component\Filesystem\Exception\FileNotFoundException;

/**
* Class Instance
Expand Down Expand Up @@ -74,7 +75,11 @@ public function getPrivateKey()
return null;
// throw new \Exception('No KeyName found');
}
return PrivateKey::get('keys/' . $keyName . '.pem');
try {
return PrivateKey::get('keys/' . $keyName . '.pem');
} catch(FileNotFoundException $e) {
return PrivateKey::get($_SERVER['HOME'] . '/keys/' . $keyName . '.pem');
}
}

/**
Expand Down

0 comments on commit b25247c

Please sign in to comment.