aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-12-27 10:02:36 -0200
committerSilvio Rhatto <rhatto@riseup.net>2016-12-27 10:02:36 -0200
commitcf0d0acb9a7b50bf4402fa0813b8d096f00ce70e (patch)
tree37ff9b848989a0e98e702486dd23599ebd884c87
parent26173dc53e88fa3e0df8ab81022401919c218c80 (diff)
downloadtermplex-cf0d0acb9a7b50bf4402fa0813b8d096f00ce70e.tar.gz
termplex-cf0d0acb9a7b50bf4402fa0813b8d096f00ce70e.tar.bz2
Setting random monitoring port for autossh
-rwxr-xr-xshell18
1 files 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