Add ssh-src-old.sh

This commit is contained in:
xanderplayz16 2024-12-24 12:01:11 -05:00
commit 299d2c2d2c

116
ssh-src-old.sh Normal file
View file

@ -0,0 +1,116 @@
#!/bin/bash
clear
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
WHITE='\033[1;37m'
RESET='\033[0m'
CPU_EMOJI="⚡"
RAM_EMOJI="📈"
STORAGE_EMOJI="🗂️"
CONNECT_EMOJI="🔗"
ERROR_EMOJI="⚠️"
ERROR_EMOJI_V2="❌"
SUCCESS_EMOJI="✅"
trap 'echo -e "\n\n${RED}${ERROR_EMOJI_V2} Script interrupted. Exiting with status 1.${RESET}\n"; exit 1' SIGINT
display_banner() {
echo -e "${CYAN}"
figlet XE-Gen11
echo -e "${WHITE}An Free/Paid VPS Hosting Company with 1.6K+ Members (discord.gg/kvm)${RESET}"
echo -e "${GREEN}======================================${RESET}"
echo
echo -e "Node Usage${RESET}"
echo -e " ${RAM_EMOJI} RAM: ${WHITE}$ram_usage${RESET}"
echo -e " ${CPU_EMOJI} CPU: ${WHITE}$cpu_usage${RESET}"
echo -e " ${STORAGE_EMOJI} Storage: ${WHITE}$storage_usage${RESET}"
echo
}
get_ram_usage() {
total_ram=$(free -m | awk '/^Mem:/ {print $2}')
used_ram=$(free -m | awk '/^Mem:/ {print $3}')
total_ram_gb=$(echo "scale=2; $total_ram/1024" | bc)
used_ram_gb=$(echo "scale=2; $used_ram/1024" | bc)
echo "${used_ram_gb}GB / ${total_ram_gb}GB"
}
get_cpu_usage() {
cpu_usage=$(top -b -n1 | grep "Cpu(s)" | awk '{print $2 + $4}')
printf "%.2f%% / CPU\n" "$cpu_usage"
}
get_storage_usage() {
total_storage=$(df -h --total | grep "total" | awk '{print $2}')
used_storage=$(df -h --total | grep "total" | awk '{print $3}')
usage_percentage=$(df -h --total | grep "total" | awk '{print $5}')
echo "${usage_percentage} / 2.5TB"
}
ram_usage=$(get_ram_usage)
cpu_usage=$(get_cpu_usage)
storage_usage=$(get_storage_usage)
display_banner
while true; do
echo -e "\n┌──(enter@token)-[~] ${RESET}"
echo -ne "${RED}└─> ${RESET}"
token=""
while IFS= read -r -s -n 1 char; do
if [[ $char == $'\0' ]]; then
break
fi
if [[ $char == $'\177' ]]; then
if [[ -n "$token" ]]; then
token=${token::-1}
echo -ne "\b \b"
fi
continue
fi
token+="$char"
echo -n "*"
done
echo
if [[ -z "$token" ]]; then
echo -e "\n${RED}${ERROR_EMOJI_V2} You must enter a valid token.${RESET}\n"
continue
fi
if ! grep -q "$token" tokens.txt; then
echo -e "\n${RED}${ERROR_EMOJI_V2} Invalid token. Please try again.${RESET}\n"
continue
fi
password=$(grep "$token" tokens.txt | cut -d ',' -f 3)
server_ip=$(grep "$token" tokens.txt | cut -d ',' -f 2)
echo -e "${CYAN}${CONNECT_EMOJI} Connecting...${RESET}"
echo
{
echo -e "${GREEN}${SUCCESS_EMOJI} Starting SSH session...${RESET}"
echo -e ""
sshpass -p "$password" ssh -o StrictHostKeyChecking=no root@$server_ip
} || {
echo -e ""
echo -e "${RED}${ERROR_EMOJI} Failed to connect.${RESET}"
echo -e ""
continue
}
clear
echo -e "${CYAN}${SUCCESS_EMOJI} SSH session ended.${RESET}"
echo -e ""
break
done
exit 0