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