From cf0d0acb9a7b50bf4402fa0813b8d096f00ce70e Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 27 Dec 2016 10:02:36 -0200 Subject: Setting random monitoring port for autossh --- shell | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/shell b/shell index 36aa30d..f07f854 100755 --- a/shell +++ b/shell @@ -1,13 +1,19 @@ #!/bin/bash # -# Simple autossh and screen wrapper. +# Simple $AUTOSSH and screen wrapper. # # Parameters +# +# We're enforcing a random monitoring por for autossh +# as some systems might deny reading /proc/net/tcp like +# kernels with grsecurity patch. BASENAME="`basename $0`" DEST="$1" COMMAND="$2" MULTIPLEXER="wscreen" +MONITORING="-M $(($RANDOM + 1024))" +AUTOSSH="autossh $MONITORING" # Set window title # http://stackoverflow.com/questions/899609/gnu-screen-run-script-that-sends-commands-to-the-screen-session-it-is-being-run @@ -31,11 +37,11 @@ window_title $DEST # Dispatcher if [ "$BASENAME" == "shells" ]; then - # Remote screen shell using autossh + # Remote screen shell using $AUTOSSH if [ "$COMMAND" == "root" ]; then - autossh $DEST -t -- sudo screen -x + $AUTOSSH $DEST -t -- sudo screen -x else - autossh $DEST -t -- screen -x $COMMAND + $AUTOSSH $DEST -t -- screen -x $COMMAND fi else if [ -z "$COMMAND" ] && screen -ls $DEST | grep -q "There is a screen on"; then @@ -54,8 +60,8 @@ else window_title $COMMAND $MULTIPLEXER $COMMAND else - # Remote shell using autossh - autossh $DEST -t -- $COMMAND + # Remote shell using $AUTOSSH + $AUTOSSH $DEST -t -- $COMMAND fi fi -- cgit v1.2.3