see http://superuser.com/questions/201003/checking-ssh-keys-have-passphrases
public static hasPassphrase ( string $keyFile ) : boolean | ||
$keyFile | string | SSH key file data |
return | boolean |
public function testHasPassphrase() { $ret = SSHKey::hasPassphrase(file_get_contents(__DIR__ . "/../../keys/id_rsa_nopass")); $this->assertEquals(false, $ret); $ret = SSHKey::hasPassphrase(file_get_contents(__DIR__ . "/../../keys/id_rsa_pass")); $this->assertEquals(true, $ret); }
public function isUsedWithPassphrase() { return SSHKey::hasPassphrase($this->getKeyContents()); }