Advertisement
dmontal2

do_keypair_2

Apr 29th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <?php
  2.  
  3. //CREATE DO KEYPAIR
  4. // Create the keypair
  5. $config = array(
  6.     "digest_alg" => "sha512",
  7.     "private_key_bits" => 4096,
  8.     "private_key_type" => OPENSSL_KEYTYPE_RSA,
  9. );
  10.    
  11. // Create the private and public key
  12. $res = openssl_pkey_new($config);
  13.  
  14.  
  15.  
  16. // Extract the private key from $res to $privKey
  17. openssl_pkey_export($res, $privKey);
  18.  
  19. $pubKey = openssl_pkey_get_details($res);
  20.  
  21. echo $pubKey["key"];
  22.  
  23. include('Crypt/RSA.php');
  24.  
  25. $rsa = new Crypt_RSA();
  26. $rsa->loadKey($res);
  27.  
  28. $privatekey = $rsa->getPrivateKey();
  29. $publickey = $rsa->getPublicKey();
  30.  
  31. echo $publickey;
  32.  
  33.  
  34. $kp_uri = "https://api.digitalocean.com/ssh_keys/new/";
  35. $kp_post = "client_id=$clientID&api_key=$apiKey&name=$keyPairName&ssh_pub_key=$pubkey";
  36.  
  37.  
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement