SSH TXT FRONTEND {sshneo.sh}

Front-end per ssh e  telnet
Crea , Cancella, visualizza  le tue sessioni in shell tramite un comodo menu, oppure apri la sessione con una semplice linea di comando.
Menu, colori e varie opzioni facilmente configurabili.

Usage:

./sshneo.sh  [nome sessione]# Per aprire direttamente una sessione

oppure

./sshneo.sh  # Per entrare nel menu

Tested on RedHat Linux


#===============================================================
# TXT FRONTEND SSH,TELNET CLIENT //  26-03-2002
#                                       Powered by Coresis Team
#===============================================================
#!/bin/sh -x

# ---> SETTING UP YOUR CONFIGURATION HERE

#Directory di appoggio
# BASE DIR
BASE_DIR=~/.sshneo

#Directory contenente i file di configurazione delle singole sessioni
# PATH TO CFG FILE
PATH_CFG_FILE=$BASE_DIR


#Nome dell'archivio creato durante il backup delle sessioni  
# BACKUP FILE
BACKUP_FILE="SavedSession"

#Colore Tabella
# TABLE COLOR
TABLECOLOR="\033[1;34m "

#Colore Testo
# TEXT COLOR
TEXTCOLOR="\033[1;34m"

#Colore neutro
#NEUTRAL COLOR
COLOROFF="\033[1;0m"

#Colore messaggi di errore
# TEXT ERROR COLOR
ERRORCOLOR="\033[1;5;31m"

#Banner superiore
# BANNER UP
BANNERUP="${TABLECOLOR}  =/=/=/=/=/=/=/=  SSH TELNET TXT FRONTEND  =/=/=/=/=/=/= \n"

#Banner inferiore
# BANNER DOWN
BANNERDOWN="${TABLECOLOR}  =/=/=/=/=/=/=/=   Version 1.5   NEO   =/=/=/=/=/=/=/= \n"

#Promt picture
# PROMPT  PICTURE
PROMPT=" -->"

#Separatore
# SEP.
SEP="===================="

#Extra options per ssh
# SSH EXTRA OPTIONS
EXTRA_OPT="-x"

#

#===========M=A=I=N===P=R=O=G=R=A=M=============#

#Screen Clean  
clear

inizializzazione di alcune funzioni  
function CON() {

case "$PROTO" in
        
        ssh | SSH )
                
                echo -e $COLOROFF      
                ssh $EXTRA_OPT -l $USER $HOST
        ;;

        telnet | TELNET )      
        
                echo -e $COLOROFF      
                telnet $HOST
        ;;
        
        *)
                echo -e " ${ERRORCOLOR}================================="
                echo -e " ${ERRORCOLOR}CONFIG FILE CORRUPTED. DELETE IT "
                echo -e " ${ERRORCOLOR}================================="
        esac
}

function LIST(){

        echo -e "${TEXTCOLOR}"
        echo "=============================="
        echo -e "      SESSIONS LIST:"
        echo "=============================="
        echo ""
        ls -1  $PATH_CFG_FILE
        echo ""
        echo "PRESS ENTER TO BACK MANI MENU"    
        read ans2
        case "$ans2" in

        *)
                clear
                main
        esac
}

#Inizializzo la funzione main  
function main() {
#creo la $BASE_DIR se non esiste
if [ ! -d  $BASE_DIR ]; then
                mkdir -p $BASE_DIR
        fi

echo ""
echo -e "$BANNERUP"
echo -e "${TEXTCOLOR}"
echo "                           "
echo "    1 - LIST SESSION       "
echo "                           "
echo "    2 - ADD NEW SESSION        "
echo "                           "
echo "    3 - DELETE SESSION         "
echo "                           "
echo "    4 - CONNECT TO...          "
echo "                           "
echo -e "    $SEP"
echo "                           "
echo "    5 - BACKUP SESSION  [ tar ]       "
echo ""
echo "    6 - CLEAR SCREEN      "
echo "                           "
echo -e "    $SEP"
echo "                           "
echo "    C - CREDITS               "
echo "                           "
echo "    0 - EXIT                  "
echo "                           "
echo -e "${COLOROFF}"
echo ""
echo -e "$BANNERDOWN"
echo ""
echo -n "$PROMPT"
read ANS

case "$ANS" in

1)
        clear
        LIST
        ;;
2)  
   clear
        echo -e $TEXTCOLOR
        echo "ENTER NAME SESSION:"
        read NEW_SES
        if [ -f $PATH_CFG_FILE/$NEW_SES ];then
                clear
                echo -e " ${ERRORCOLOR}======================================"
                echo -e " ${ERRORCOLOR}SESSION EXIST,PLEASE ENTER OTHER NAME"
                echo -e " ${ERRORCOLOR}======================================"
                main
        else
                if [ "$NEW_SES" = "" ];then
                        clear
                        echo -e " ${ERRORCOLOR}==================================="
                        echo -e " ${ERRORCOLOR}ENTER A VALID SESSION NAME,PLEASE"
                        echo -e " ${ERRORCOLOR}==================================="
                        main
                else
                        echo "ENTER TYPE SESSION: [ telnet or ssh ]:"  
                        read NEW_PROTO
                        echo "ENTER IP OR HOST NAME:"
                        read NEW_HOST
                        echo "ENTER USERNAME:"
                        read NEW_USER
                        touch $PATH_CFG_FILE/$NEW_SES
                        echo "PROTO=$NEW_PROTO" >> $PATH_CFG_FILE/$NEW_SES
                        echo "HOST=$NEW_HOST" >> $PATH_CFG_FILE/$NEW_SES
                        echo "USER=$NEW_USER" >> $PATH_CFG_FILE/$NEW_SES
        
        fi

fi
        main
;;
3)
        clear
        echo ""
        echo -e $TEXTCOLOR
        echo "ENTER NAME SESSION TO DELETE:"
        read NEW_SES
        if [ -f $PATH_CFG_FILE/$NEW_SES ];then
                rm -f $PATH_CFG_FILE/$NEW_SES
                main    
        else
                clear
                echo -e " ${ERRORCOLOR}===================================="    
                echo -e " ${ERRORCOLOR}ENTER NAME SESSION CORRECT PLEASE!!"    
                echo -e " ${ERRORCOLOR}===================================="    
                main
        fi
        ;;
4)
        clear
        echo ""
        echo -e "${TEXTCOLOR}"
        echo "=============================="
        echo -e "      SESSIONS LIST:"
        echo "=============================="
        echo ""
        ls -1  $PATH_CFG_FILE
        echo ""
        echo "ENTER NAME SESSION:"
        read SES
        if [ -f $PATH_CFG_FILE/$SES ];then
                clear
                echo " START CONNECTION TO $SES..."            
                . $PATH_CFG_FILE/$SES
        else
                clear
                echo -e " ${ERRORCOLOR}================================================"        
                echo -e " ${ERRORCOLOR}SESSION NOT EXIST, PLEASE VIEW SESSIONS LIST !"  
                echo -e " ${ERRORCOLOR}================================================"        
                main
        fi
        CON ;;
5)
        clear
        echo "BACKUP SESSIONS IN PROGRESS..."
        echo -e $ERRORCOLOR
        tar -Pcvf ~/$BACKUP_FILE.tar $PATH_CFG_FILE
        echo ""
        echo SESSION SAVED IN ~/$BACKUP_FILE.tar
        echo ""
        echo -e $TEXTCOLOR
        echo "BACKUP TERMINATED, PRESS ENTER TO BACK MAIN MENU"
        read RETURN1
        case "$RETURN1" in
                *)
                        clear
                        main
                esac
        ;;

6)
        clear
        main
        ;;

C | c)
        clear
        echo -e "$BANNERUP"
        echo ""
        echo "   TXT FRONTEND FOR TELNET AND SSH "
        echo "   CREATED BY NEO > UNDER GPL LICENSE"
        echo " "
        echo "   PRESS ENTER TO BACK MAIN MENU"
        echo ""
        echo "   HAVE A NICE DAY!"
        echo ""
        echo -e "$BANNERDOWN"
        read RETURN
        case "$RETURN" in
                *)
                        clear
                        main            
                esac

        ;;
0 | exit | EXIT | BYE | bye)
        
        echo -e $TEXTCOLOR
        echo "HAVE A NICE DAY!"
        sleep 1
        clear
        if [ -f $TMP_FILE ]; then
                rm -f $TMP_FILE
        fi

        echo -e $COLOROFF
        exit 0;;
*)
        clear
        main

esac

}
#Verifica dell'esistenza di un parametro,se esiste verifica che corrisponda al nome di una sessione,altrimenti visualizza il menu principale
if [ "$1" = "" ]; then
        main  
else
                if [ -f $PATH_CFG_FILE/$1  ]; then
                echo -e $TEXTCOLOR
                echo " START CONNECTION TO $1..."
                . $PATH_CFG_FILE/$1            
                CON
        else
                echo -e $ERRORCOLOR
                echo "============================================="
                echo " SESSION NOT EXIST, VIEW THE SESSION LIST! "
                echo "============================================="
                main
        fi      
fi

Privacy Policy