本文整理汇总了PHP中phpseclib\Crypt\RSA::setComment方法的典型用法代码示例。如果您正苦于以下问题:PHP RSA::setComment方法的具体用法?PHP RSA::setComment怎么用?PHP RSA::setComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpseclib\Crypt\RSA
的用法示例。
在下文中一共展示了RSA::setComment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateKeyPair
public static function generateKeyPair($comment = 'dogpro')
{
$rsa = new RSA();
$rsa->setPublicKeyFormat(RSA::PUBLIC_FORMAT_OPENSSH);
$rsa->setComment($comment);
return $rsa->createKey();
}
示例2: createRSA
protected function createRSA()
{
$rsa = new RSA();
$rsa->setPublicKeyFormat(RSA::PUBLIC_FORMAT_OPENSSH);
$rsa->setComment($this->config['routerboard']['backupuser'] . "@backup");
$key = $rsa->createKey(2048);
if (!empty($key)) {
// be safe
$this->backupExistRSA();
// create id_rsa.pub (public key)
$this->fsys->dumpFile($this->config['system']['ssh-dir'] . DIRECTORY_SEPARATOR . 'id_rsa.pub', $key['publickey']);
// create id_rsa (private key)
$this->fsys->dumpFile($this->config['system']['ssh-dir'] . DIRECTORY_SEPARATOR . 'id_rsa', $key['privatekey']);
// set permissions -rw-------
$this->fsys->chmod($this->config['system']['ssh-dir'] . DIRECTORY_SEPARATOR . 'id_rsa', 0600);
$this->fsys->chmod($this->config['system']['ssh-dir'] . DIRECTORY_SEPARATOR . 'id_rsa.pub', 0600);
// backup existing RSA files for sure.
$this->backupExistRSA('routerboard-backup');
$this->logger->log("The SSH-RSA public key has been created. Never delete those files! (id_rsa,id_rsa.pub)", $this->logger->setNotice());
return;
}
throw new Exception(get_class($this) . " can not create the ssh-rsa public key file!");
}
示例3: getPair
public function getPair()
{
$installationUuid = $this->name;
$publicKeyName = $this->getPublicKeyPath();
$privateKeyName = $this->getPrivateKeyPath();
if (Storage::exists($publicKeyName) === false || Storage::exists($privateKeyName) === false) {
$rsa = new RSA();
$rsa->setPublicKeyFormat(RSA::PUBLIC_FORMAT_OPENSSH);
$rsa->setComment('fodor@fodor.xyz');
$keys = $rsa->createKey(2048);
$privateKey = $keys['privatekey'];
$publicKey = $keys['publickey'];
Storage::disk('local')->put($privateKeyName, $privateKey);
Storage::disk('local')->put($publicKeyName, $publicKey);
}
return ['public' => $publicKeyName, 'private' => $privateKeyName];
/*$sshConnection = ssh2_connect('mycloud.smellynose.com', 22, array('hostkey'=>'ssh-rsa'));
$sshSuccess = ssh2_auth_pubkey_file(
$sshConnection,
'ahindle',
storage_path('app/' . $publicKeyName),
storage_path('app/' . $privateKeyName)
);*/
}