Altax\Util\SSHKey::hasPassphrase PHP Method

hasPassphrase() public static method

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 static function hasPassphrase($keyFile)
    {
        if (preg_match("/Proc-Type.+ENCRYPTED/", $keyFile) === 1) {
            return true;
        } else {
            return false;
        }
    }

Usage Example

Ejemplo n.º 1
0
 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);
 }
All Usage Examples Of Altax\Util\SSHKey::hasPassphrase