Compare commits

..

14 Commits

Author SHA1 Message Date
b098163830 Update renewkeys.sh 2026-02-23 19:41:03 -05:00
d70e3970ba Remove useless temp folder creation 2026-02-23 15:05:21 -05:00
7de10677d3 Fix script errors (again) 2026-02-23 14:58:26 -05:00
16d07c1f8e Fix script errors 2026-02-23 14:55:59 -05:00
66cb6ae4f4 Fix directory if 2026-01-31 22:25:03 -05:00
44a566dadc Fix folder finder 2026-01-31 22:24:04 -05:00
38bc39eb05 Fix find cmd 2026-01-31 22:23:36 -05:00
6f0992de49 Change directory deletion for file deletion instead 2026-01-31 22:23:04 -05:00
de5a8240a8 Fix directory erase 2026-01-31 22:21:01 -05:00
8162a423f6 Update updatescripts.sh 2026-01-31 22:19:52 -05:00
00c6b48890 Update updatescripts.sh 2026-01-31 22:19:01 -05:00
a153a40cf1 Merge pull request 'Direct to CDN test is successful' (#1) from direct-cdn into main
Reviewed-on: #1
2026-01-31 22:06:00 -05:00
9e37c6b522 Fix known_hosts rm to detect if file is present first 2026-01-31 22:03:42 -05:00
caaf96cedb Update renewkeys.sh 2026-01-31 21:58:41 -05:00
3 changed files with 75 additions and 57 deletions

View File

@@ -11,10 +11,14 @@ fi
##Generate keys ##Generate keys
mkdir /.SSH/automated/.temp mkdir /.SSH/automated/.temp
ssh-keygen -f /.SSH/automated/.temp/id_ed25519 -N "" && ssh-keygen -f /.SSH/automated/.temp/id_ed25519 -N "" &&
if [ -f /.SSH/automated/priv/servers/id_ed25519 ]; then
rm /.SSH/automated/priv/servers/id_ed25519 rm /.SSH/automated/priv/servers/id_ed25519
fi
if [ -f /.SSH/automated/pub/servers/id_ed25519.pub ]; then
rm /.SSH/automated/pub/servers/id_ed25519.pub rm /.SSH/automated/pub/servers/id_ed25519.pub
/.SSH/automated/.temp/id_ed25519 > /.SSH/automated/priv/servers/ fi
/.SSH/automated/.temp/id_ed25519.pub > /.SSH/automated/pub/servers/ cat /.SSH/automated/.temp/id_ed25519 > /.SSH/automated/priv/servers/id_ed25519
cat /.SSH/automated/.temp/id_ed25519.pub > /.SSH/automated/pub/servers/id_ed25519.pub
sha256sum /.SSH/automated/.temp/id_ed25519 | awk '{print $1}' > /home/$USER/sshprov/priv sha256sum /.SSH/automated/.temp/id_ed25519 | awk '{print $1}' > /home/$USER/sshprov/priv
sha256sum /.SSH/automated/.temp/id_ed25519.pub | awk '{print $1}' > /home/$USER/sshprov/pub sha256sum /.SSH/automated/.temp/id_ed25519.pub | awk '{print $1}' > /home/$USER/sshprov/pub
sleep 2 sleep 2
@@ -25,14 +29,14 @@ rm /home/$USER/.ssh/known_hosts
rm /root/.ssh/known_hosts rm /root/.ssh/known_hosts
rm /root/.ssh/id_ed25519 rm /root/.ssh/id_ed25519
rm /root/.ssh/authorized_keys rm /root/.ssh/authorized_keys
/.SSH/automated/priv/servers/id_ed25519 > /root/.ssh/id_ed25519 cat /.SSH/automated/priv/servers/id_ed25519 > /root/.ssh/id_ed25519
/.SSH/automated/pub/servers/id_ed25519.pub > /root/.ssh/authorized_keys && cat /.SSH/automated/pub/servers/id_ed25519.pub > /root/.ssh/authorized_keys &&
chmod 700 /root/.ssh/id_ed25519 chmod 700 /root/.ssh/id_ed25519
chmod 644 /root/.ssh/authorized_keys chmod 644 /root/.ssh/authorized_keys
rm /home/$USER/.ssh/id_ed25519 rm /home/$USER/.ssh/id_ed25519
rm /home/$USER/.ssh/authorized_keys rm /home/$USER/.ssh/authorized_keys
/.SSH/automated/priv/servers/id_ed25519 > /home/$USER/.ssh/id_ed25519 cat /.SSH/automated/priv/servers/id_ed25519 > /home/$USER/.ssh/id_ed25519
/.SSH/automated/pub/servers/id_ed25519.pub > /home/$USER/.ssh/authorized_keys && cat /.SSH/automated/pub/servers/id_ed25519.pub > /home/$USER/.ssh/authorized_keys &&
chmod 700 /home/$USER/.ssh chmod 700 /home/$USER/.ssh
chmod 600 /home/$USER/.ssh/id_ed25519 chmod 600 /home/$USER/.ssh/id_ed25519
chmod 600 /home/$USER/.ssh/authorized_keys chmod 600 /home/$USER/.ssh/authorized_keys

View File

@@ -9,14 +9,22 @@ PC=$(uname -n | awk '{print $1}')
guardband() { guardband() {
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo -e "${CY}Cleaning up temp directory for checksums...${NF}"
rm -rf /.SSH/.temp
sleep 2
echo -e "${CR}Script Exited with an Error.${NF}" echo -e "${CR}Script Exited with an Error.${NF}"
exit 1 exit 1
fi fi
} }
cleanup() {
echo -e "${CR}Attention: Script in fix mode - This will reset the .ssh folder. Press CTRL+C ${FB}NOW${NF} ${CR}if you want to avoid this.${NF}"
sleep 5
if [[ $1 = "--pve01" ]]; then
find /root/.ssh/ -type f -delete
else
find /root/.ssh/ -type f -delete
find /home/$USER/.ssh/ -type f -delete
fi
}
verifycdn(){ verifycdn(){
CDN="https://cdn.franscorack.com" CDN="https://cdn.franscorack.com"
echo -e "${CY}Verifying CDN availability...${NF}" echo -e "${CY}Verifying CDN availability...${NF}"
@@ -26,29 +34,13 @@ if ! wget --spider "$CDN" 2>/dev/null; then
return 1 return 1
else else
echo -e "${CG}CDN available for checksum downloads - ${FB}Proceeding...${NF}" echo -e "${CG}CDN available for checksum downloads - ${FB}Proceeding...${NF}"
serversidePUB=$(wget https://cdn.franscorack.com/chksum/sshprov/pub -q -O -)
serversidePRIV=$(wget https://cdn.franscorack.com/chksum/sshprov/priv -q -O -)
sleep 2 sleep 2
fi fi
} }
downloadpub(){
wget -q https://cdn.franscorack.com/chksum/sshprov/pub -O /.SSH/.temp/pub
if [ $? -ne 0 ]; then
echo -e "${CR}Download error: CDN reported error in file download${NF}"
return 1
fi
}
downloadpriv(){
wget -q https://cdn.franscorack.com/chksum/sshprov/priv -O /.SSH/.temp/priv
if [ $? -ne 0 ]; then
echo -e "${CR}Download error: CDN reported error in file download${NF}"
return 1
fi
}
rootcheck(){ rootcheck(){
serversidePRIV=$(cat /.SSH/.temp/priv | awk '{print $1}')
serversidePUB=$(cat /.SSH/.temp/pub | awk '{print $1}')
if [ -f /root/.ssh/id_ed25519 ]; then if [ -f /root/.ssh/id_ed25519 ]; then
rootPRIV=$(sha256sum /root/.ssh/id_ed25519 | awk '{print $1}') rootPRIV=$(sha256sum /root/.ssh/id_ed25519 | awk '{print $1}')
else else
@@ -198,35 +190,44 @@ if [ "$UID" -ne 0 ]; then
fi fi
echo -e ${CY}Warning: running this script resets known_hosts file. Abort this script using CTRL+C if you want to avoid that.${NF} echo -e ${CY}Warning: running this script resets known_hosts file. Abort this script using CTRL+C if you want to avoid that.${NF}
sleep 3 sleep 3
if [ -f /home/$USER/.ssh/known_hosts ]; then
rm /home/$USER/.ssh/known_hosts rm /home/$USER/.ssh/known_hosts
fi
if [ -f /root/.ssh/known_hosts ]; then
rm /root/.ssh/known_hosts rm /root/.ssh/known_hosts
if [ ! -f ".SSH/.temp" ]; then
mkdir /.SSH/.temp
fi fi
if [ "$PC" = "pve01" ] if [[ $1 = "--fix" ]]; then
then if [ "$PC" = "pve01" ]
verifycdn then
guardband cleanup --pve01
downloadpub verifycdn
guardband guardband
downloadpriv rootcheck
guardband guardband
rootcheck else
guardband cleanup
else verifycdn
verifycdn guardband
guardband rootcheck
downloadpub guardband
guardband admincheck
downloadpriv guardband
guardband fi
rootcheck else
guardband if [ "$PC" = "pve01" ]
admincheck then
guardband verifycdn
guardband
rootcheck
guardband
else
verifycdn
guardband
rootcheck
guardband
admincheck
guardband
fi
fi fi
sleep 3
echo -e "${CY}Cleaning up temp directory for checksums...${NF}"
rm -rf /.SSH/.temp
sleep 2 sleep 2
echo -e "${CG}Script execution completed.${NF}" echo -e "${CG}Script execution completed.${NF}"

View File

@@ -14,9 +14,6 @@ fi
guardband() { guardband() {
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo -e "${CY}Cleaning up temp directory...${NF}"
rm -rf /.SSH/automated/.temp/
sleep 2
echo -e "${CR}Script Exited with an Error.${NF}" echo -e "${CR}Script Exited with an Error.${NF}"
exit 1 exit 1
fi fi
@@ -33,4 +30,20 @@ if ! wget --spider "$SRV" 2>/dev/null; then
echo -e "${CG}Server available - ${FB}Proceeding...${NF}" echo -e "${CG}Server available - ${FB}Proceeding...${NF}"
sleep 2 sleep 2
fi fi
} }
updatescripts(){
if [ ! -d /.SSH/script ]; then
mkdir /.SSH/script
fi
find /.SSH/script -name "*.sh" -delete
wget -q https://git.franscorack.com/Franscobec/AutoremakeSSH/raw/branch/main/renewkeys.sh -O /.SSH/script/renewkeys.sh
wget -q https://git.franscorack.com/Franscobec/AutoremakeSSH/raw/branch/main/deploy-newssh.sh -O /.SSH/script/deploy-newssh.sh
wget -q https://git.franscorack.com/Franscobec/AutoremakeSSH/raw/branch/main/autoremakekeys.sh -O /.SSH/script/autoremakekeys.sh
wget -q https://git.franscorack.com/Franscobec/AutoremakeSSH/raw/branch/main/updatescripts.sh -O /.SSH/script/updatescripts.sh
}
verifygit
guardband
updatescripts
guardband