コード例 #1
0
    show_header('GENI Portal: Profile', $load_user);
    include "tool-breadcrumbs.php";
    print '<h1>An error occurred while generating your SSH keypair.</h1>';
    include "footer.php";
    exit;
}
/* ssh keys (public and private) were successfully generated. Store them in the database. */
$private_key = file_get_contents($privatekeyfile);
$public_key = file_get_contents($publickeyfile);
unlink($privatekeyfile);
unlink($publickeyfile);
/* This is the name of the file on the experimenter's machine. */
$filename = "id_geni_ssh_rsa";
$description = "Generated SSH keypair";
$ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY);
$result = register_ssh_key($ma_url, $user, $user->account_id, $filename, $description, $public_key, $private_key);
if (is_array($result) && array_key_exists(RESPONSE_ARGUMENT::CODE, $result) && $result[RESPONSE_ARGUMENT::CODE] != RESPONSE_ERROR::NONE) {
    error_log("Failed to register SSH key for account " . $user->account_id . " from file {$filename}: " . $result);
    $_SESSION['lasterror'] = "ERROR Generating SSH keypair";
    relative_redirect('profile.php');
}
if (True) {
    $_SESSION['lastmessage'] = "Generated SSH keypair - now download the private key";
    relative_redirect('profile.php#ssh');
} else {
    // Set headers for download
    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-Disposition: attachment; filename={$filename}");
    header("Content-Type: application/pem");
    header("Content-Transfer-Encoding: binary");
コード例 #2
0
ファイル: uploadsshkey.php プロジェクト: ahelsing/geni-portal
    if ($error != NULL) {
        echo "<div id=\"error-message\"" . " style=\"background: #dddddd;font-weight: bold\">\n";
        echo "{$error}";
        echo "</div>\n";
    }
    include 'uploadsshkey.html';
    // show button only if there are no SSH keys on file
    // don't let user generate public/private keypair if
    // they already have 1+ public keys on file
    $keys = $user->sshKeys();
    if (count($keys) == 0) {
        echo "<p>If you don't have an SSH keypair or want to create a new SSH keypair, <button onClick=\"window.location='generatesshkey.php'\">generate and download an SSH keypair</button>.</p>";
    }
    include "footer.php";
    exit;
}
// The public key is in $_FILES["file"]["tmp_name"]
$contents = file_get_contents($_FILES["file"]["tmp_name"]);
$filename = $_FILES["file"]["name"];
$description = NULL;
if (array_key_exists("description", $_POST)) {
    $description = $_POST["description"];
}
$ma_url = get_first_service_of_type(SR_SERVICE_TYPE::MEMBER_AUTHORITY);
register_ssh_key($ma_url, $user, $user->account_id, $filename, $description, $contents);
$_SESSION['lastmessage'] = "Uploaded SSH public key from " . $_FILES["file"]["name"];
relative_redirect('profile');
?>
Your key was uploaded.<br/>
<a href="profile.php">My Profile page</a>