#!/usr/local/cpanel/3rdparty/bin/perl # gniza WHM Plugin — Setup Wizard # Step 1: SSH Key selection, then redirects to remotes.cgi and schedules.cgi use strict; use warnings; use lib '/usr/local/cpanel/whostmgr/docroot/cgi/gniza-whm/lib'; use Whostmgr::HTMLInterface (); use Cpanel::Form (); use GnizaWHM::UI; my $form = Cpanel::Form::parseform(); handle_step1(); exit; # ── Step 1: SSH Key ────────────────────────────────────────── sub handle_step1 { print "Content-Type: text/html\r\n\r\n"; Whostmgr::HTMLInterface::defheader('gniza Setup Wizard', '', '/cgi/gniza-whm/setup.cgi'); print GnizaWHM::UI::page_header('gniza Setup Wizard'); my $keys = GnizaWHM::UI::detect_ssh_keys(); print qq{
\n
\n}; print qq{

Step 1: SSH Key

\n}; print qq{

gniza uses SSH keys to connect to remote backup destinations. Select an existing key or create one first.

\n}; if (@$keys) { print qq{
\n}; print qq{

Existing keys found:

\n}; print qq{\n}; print qq{\n}; print qq{\n}; my $first = 1; for my $k (@$keys) { my $checked = $first ? ' checked' : ''; my $pub = $k->{has_pub} ? 'Available' : 'Missing'; my $esc_path = GnizaWHM::UI::esc($k->{path}); my $esc_type = GnizaWHM::UI::esc($k->{type}); print qq{}; print qq{}; print qq{}; print qq{}; print qq{}; print qq{\n}; $first = 0; } print qq{\n
TypePathPublic Key
$esc_type$esc_path$pub
\n}; print qq{
\n}; print qq{ \n}; print qq{ \n}; print qq{ \n}; print qq{
\n}; print qq{
\n}; print qq{
\n}; print qq{\n}; print qq{\n}; print qq{
\n}; print qq{ \n}; print qq{ \n}; print qq{
\n}; print qq{
\n}; } else { print qq{
No SSH keys found in /root/.ssh/. You need to create one first.
\n}; } # Always show key generation instructions print qq{
\n}; print qq{

Generate a new SSH key (if needed):

\n}; print qq{
ssh-keygen -t ed25519 -f /root/.ssh/id_ed25519 -N ""
\n}; print qq{

Copy the public key to the remote server:

\n}; print qq{
ssh-copy-id -i /root/.ssh/id_ed25519.pub user\@host
\n}; print qq{

Run these commands in WHM → Server Configuration → Terminal, or via SSH.

\n}; print qq{
\n}; unless (@$keys) { print qq{
\n}; print qq{\n}; print qq{\n}; print qq{
\n}; print qq{ \n}; print qq{ \n}; print qq{
\n}; print qq{
\n}; print qq{ \n}; print qq{ \n}; print qq{
\n}; print qq{
\n}; } print qq{
\n
\n}; # JS to resolve selected key into key_path param print <<'JS'; JS print GnizaWHM::UI::page_footer(); Whostmgr::HTMLInterface::footer(); }