在laravel ssh密钥生成中找不到类'phpseclib \ Crypt \ RSA'

时间:2019-05-20 07:02:50

标签: php laravel ssh rsa

请检查代码。 我的代码在这里:

use phpseclib\Crypt\RSA;
use SSH;
use Storage;

class SSHController extends Controller
{
    public function key($key)
    {
    try {
        $rsa = new RSA();
        $rsa->setPublicKeyFormat(RSA::PUBLIC_FORMAT_OPENSSH);
        $keys = $rsa->createKey(2048);
        $private = $keys['privatekey'];
        $public = $keys['publickey'];

        Storage::disk('localKeys')->put($key,$private);
        Storage::disk('localKeys')->put($key.'.pub',$public);

        return $public;
    } catch (\Exception $e){
        \Log::error("Failed to generate SSH key. Error message -> ".$e->getMessage());
        return response()->json([
            'message' => "Something went really wrong!"
        ],500);
    }
}
}

我尝试了最近五个小时,但没有任何反应。 Laravel 5.7在系统中使用。 高级谢谢您的帮助!

0 个答案:

没有答案