/** * @small * @expectedException \Bravo3\SSH\Exceptions\UnsupportedException */ public function testUnknownKeyGeneration() { $keyfile = __DIR__ . '/../../resources/ecdsa-pw.pem'; $password = '******'; $util = new KeyUtility(); $util->generateSshPublicKey('file://' . $keyfile, $password); }
/** * Automatically generate the public key from the private key * * The public key file will be removed when this class is destroyed. This function is automatically called when you * attempt to authenticate without a public key file. * * @param string $tmp_file Filename to save the public key, uses a temp file if omitted * @throws FileNotExistsException */ public function generatePublicKey($tmp_file = null) { if (!$this->getPrivateKey()) { throw new FileNotExistsException("Missing private key file"); } $util = new KeyUtility(); $pubkey = $util->generateSshPublicKey('file://' . $this->getPrivateKey()); $pubkey_file = $tmp_file ?: tempnam(sys_get_temp_dir(), 'ssh_pkey_'); file_put_contents($pubkey_file, $pubkey); $this->public_key = $pubkey_file; $this->using_tmp_key = true; }