list incoming ssh too
This commit is contained in:
@@ -36,31 +36,42 @@ colRow="\033[0;1m"
|
||||
colMenu="\033[0;33m"
|
||||
colWarn="\033[0;1;31m"
|
||||
|
||||
function fpgrep() {
|
||||
pgrep -x -u $UID "$@" | xargs --no-run-if-empty ps -o pid,bsdtime,args;
|
||||
test ${PIPESTATUS[0]} -ne 0 && echo '----'
|
||||
}
|
||||
|
||||
function get_id() {
|
||||
id=$( printf "%s" "$line" | base64 -w 0 )
|
||||
echo -n $id
|
||||
}
|
||||
|
||||
function get_command() {
|
||||
switches=$( echo "$1" | base64 -d )
|
||||
echo -n "ssh -f -n $switches \"sleep $MAGIC_TIME; echo tunneler $1\""
|
||||
}
|
||||
|
||||
function get_pid() {
|
||||
pgrep -f "$MAGIC_TIME.*echo tunneler $1" | head -n 1
|
||||
}
|
||||
|
||||
function list_all_ssh() {
|
||||
printf "\n${colTitle}=============================================\n"
|
||||
printf "${colTitle} List of SSH:${colZ}\n"
|
||||
printf "${colTitle}Enter PID to kill, empty to return $colZ\n"
|
||||
printf "${colTitle}=============================================\n"
|
||||
printf "${colRow}PID command\n"
|
||||
pgrep -a -x ssh
|
||||
printf "${colTitle}Outgoing SSH processes\n"
|
||||
printf "${colTitle}=============================================\n${colRow}"
|
||||
fpgrep ssh
|
||||
printf "${colTitle}Incoming SSH processes\n"
|
||||
printf "${colTitle}=============================================\n${colRow}"
|
||||
fpgrep sshd
|
||||
read -t 600 inputpid
|
||||
|
||||
[[ "$inputpid" =~ $number_re ]] && {
|
||||
kill $inputpid
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function read_config() {
|
||||
while read line; do
|
||||
id=$( get_id "$line" )
|
||||
@@ -70,6 +81,7 @@ function read_config() {
|
||||
i=$(( i + 1 ))
|
||||
done < <( grep -v ^# "$CONF" | grep '[a-zA-Z]' )
|
||||
}
|
||||
|
||||
function run_command() {
|
||||
eval $( get_command "$1" )
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user