LibrePortal/scripts/ssh/keys/setup_key_pair.sh
librelad 875a60f90f LibrePortal v0.1.0 — initial release
A free, open, self-hosted app platform (GNU AGPLv3): one-click app deploys,
Traefik reverse proxy with automatic SSL, rootless Docker support, gluetun
VPN routing, and a web dashboard to manage it all.

Free & open forever to self-host; optional paid hosted services fund it.
See PROMISE.md.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-21 20:37:54 +01:00

36 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
generateSSHSetupKeyPair()
{
local username="$1"
local flag="$2"
local private_key_file="${CFG_INSTALL_NAME}_sshkey_$username"
local private_key_path="${ssh_dir}private"
local private_key_full="$private_key_path/$private_key_file"
local public_key_file="$private_key_file.pub"
local public_key_path="${ssh_dir}public"
local public_key_full="$public_key_path/$public_key_file"
# Check if the directory exists; if not, create it
if [ ! -d "$private_key_path" ]; then
local result=$(createFolders "loud" $docker_install_user $private_key_path)
checkSuccess "Creating $(basename "$private_key_path") folder"
fi
if [ ! -d "$public_key_path" ]; then
local result=$(createFolders "loud" $docker_install_user $public_key_path)
checkSuccess "Creating $(basename "$public_key_path") folder"
fi
# Check if the private key does not exist
if [ ! -f "$private_key_full" ]; then
generateSSHKeyPair "$username" "$private_key_path" "$private_key_full" "$public_key_full" install;
fi
# Check if the public key does not exist
if [ ! -f "$public_key_full" ]; then
generateSSHKeyPair "$username" "$private_key_path" "$private_key_full" "$public_key_full" install;
fi
}