Compare commits
14 Commits
dea41f3e8f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| b098163830 | |||
| d70e3970ba | |||
| 7de10677d3 | |||
| 16d07c1f8e | |||
| 66cb6ae4f4 | |||
| 44a566dadc | |||
| 38bc39eb05 | |||
| 6f0992de49 | |||
| de5a8240a8 | |||
| 8162a423f6 | |||
| 00c6b48890 | |||
| a153a40cf1 | |||
| 9e37c6b522 | |||
| caaf96cedb |
@@ -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
|
||||||
|
|||||||
95
renewkeys.sh
95
renewkeys.sh
@@ -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}"
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user