From 9416a65e0f8cd87e75a9af6cd1c79e6b4d3c4a83 Mon Sep 17 00:00:00 2001 From: Franscobec Date: Fri, 9 Jan 2026 22:58:25 -0500 Subject: [PATCH] Add deploy-newssh.sh --- deploy-newssh.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 deploy-newssh.sh diff --git a/deploy-newssh.sh b/deploy-newssh.sh new file mode 100644 index 0000000..cafa490 --- /dev/null +++ b/deploy-newssh.sh @@ -0,0 +1,49 @@ +#!/bin/bash +NO_FORMAT="\e[0m" +F_BOLD="\e[1m" +C_GREEN="\e[38;5;40m" +C_RED="\e[38;5;9m" +C_YELLOW="\033[38;5;226m" +USER=$(getent passwd 1000 | cut -d: -f1) + +#Verify if root +if [ "$UID" -ne 0 ]; then + echo -e "${C_RED}This script must be run as root.${NO_FORMAT}" + exit 1 +fi + +#Verify provisioning server availability +URL="https://prov.franscorack.com" + +if ! wget --spider "$URL" 2>/dev/null; then + echo -e "${C_RED}Error: Cannot reach intranet provisioning server - ${F_BOLD}Are you not on LAN or VPN ? / Is it down ?${NO_FORMAT}" + echo -e "${C_RED}Initialization script can only be ran if $URL is reachable. Script Halted. ${NO_FORMAT}" + exit 1 +fi +if [ -f "/.SSH/script/renew-keys.sh" ]; then + echo -e "${C_GREEN}Script already present. Skipping...${NO_FORMAT}" + else + echo -e "${C_RED}Script not found. Downloading...${NO_FORMAT}" + mkdir /.SSH + mkdir /.SSH/script + wget https://prov.franscorack.com/script/renew-keys.sh -O /.SSH/script/renew-keys.sh + sleep 2 +fi +rm -rf /home/$USER/.ssh +mkdir /home/$USER/.ssh +touch /home/$USER/.ssh/id_ed25519 +touch /home/$USER/.ssh/authorized_keys +chmod 700 -R /home/$USER/.ssh +chown $USER -R /home/$USER/.ssh +mkdir /.SSH +mkdir /.SSH/automated +mkdir /.SSH/automated/.stfolder +mkdir /.SSH/automated/priv +mkdir /.SSH/automated/pub +mkdir /.SSH/automated/priv/servers +mkdir /.SSH/automated/pub/servers +touch /.SSH/automated/priv/servers/id_ed25519 +touch /.SSH/automated/pub/servers/id_ed25519.pub +echo -e "${C_YELLOW}Launching key fetching script in 5 seconds. Press CTRL+C to abort.${NO_FORMAT}" +sleep 5 +sh /.SSH/script/renew-keys.sh \ No newline at end of file