]> gitweb.fluxo.info Git - termplex.git/commitdiff
Initial import
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 18 Sep 2014 19:36:52 +0000 (16:36 -0300)
committerSilvio Rhatto <user@example.org>
Thu, 18 Sep 2014 19:36:52 +0000 (16:36 -0300)
README.md [new file with mode: 0644]
TODO.md [new file with mode: 0644]
shell [new file with mode: 0755]
shells [new symlink]
wscreen [new file with mode: 0755]

diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/TODO.md b/TODO.md
new file mode 100644 (file)
index 0000000..6431f05
--- /dev/null
+++ b/TODO.md
@@ -0,0 +1,8 @@
+TODO
+====
+
+* Enhanced shell:
+  * Add a counter-measure to prevent SSH timing attacks:
+    http://users.ece.cmu.edu/~dawnsong/papers/ssh-timing.pdf
+    http://www.slideshare.net/idsecconf/countermeasure-against-timing-attack-on-ssh-using-random-delay
+    http://www.scribd.com/doc/59628153/Timing-Analysis-of-Keystrokes-and-Timing-Attacks-on-SSH-Revisited
diff --git a/shell b/shell
new file mode 100755 (executable)
index 0000000..e2a48c1
--- /dev/null
+++ b/shell
@@ -0,0 +1,54 @@
+#!/bin/bash
+#
+# Simple autossh and screen wrapper.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+DEST="$1"
+COMMAND="$2"
+
+# Set screen title
+# http://stackoverflow.com/questions/899609/gnu-screen-run-script-that-sends-commands-to-the-screen-session-it-is-being-run
+function screen_title {
+  if [ -n "$STY" ]; then
+    screen -X title $1
+  fi
+}
+
+# Syntax check
+if [ -z "$DEST" ]; then
+  exit 1
+fi
+
+# Set default screen title
+screen_title $DEST
+
+# Dispatcher
+if [ "$BASENAME" == "shells" ]; then
+  # Remote screen shell using autossh
+  if [ "$COMMAND" == "root" ]; then
+    autossh $DEST -t -- sudo screen -x
+  else
+    autossh $DEST -t -- screen -x $COMMAND
+  fi
+else
+  if [ -z "$COMMAND" ] && screen -ls $DEST | grep -q "There is a screen on"; then
+    # Local existing screen shell
+    wscreen $DEST
+  elif [ -z "$COMMAND" ] && [ "$DEST" == "root" ]; then
+    # Local root shell
+    screen_title root
+    sudo screen -x
+  elif [ "$DEST" == "local" ]; then
+    # Local screen shell
+    screen_title $COMMAND
+    wscreen $COMMAND
+  else
+    # Remote shell using autossh
+    autossh $DEST -t -- $COMMAND
+  fi
+fi
+
+# Restore screen title
+screen_title terminal
diff --git a/shells b/shells
new file mode 120000 (symlink)
index 0000000..03e813f
--- /dev/null
+++ b/shells
@@ -0,0 +1 @@
+shell
\ No newline at end of file
diff --git a/wscreen b/wscreen
new file mode 100755 (executable)
index 0000000..f4a1f4c
--- /dev/null
+++ b/wscreen
@@ -0,0 +1,39 @@
+#
+# Workscreen: screen session wrapper
+#
+# Alternative:
+# http://byobu.co
+# http://packages.debian.org/stable/byobu
+#
+
+# Default options.
+opts="-c /etc/screenrc"
+
+# Remove dead screens.
+screen -wipe &> /dev/null
+
+# Session selection.
+if [ ! -z "$1" ]; then
+  if screen -ls $1 | grep -q "There is a screen on"; then
+    #echo "There's already a screen called $1"
+    #exit 1
+    screen -x $1
+    exit $?
+  else
+    session="-S $1"
+  fi
+
+  if [ "$1" == "main" ]; then
+    opts=""
+  elif [ "$1" == "root" ]; then
+    sudo screen -x
+    exit
+  elif [ -f "$HOME/.screen/$1" ]; then
+    opts="-c $HOME/.screen/$1"
+  elif [ -f "$HOME/.screen/base" ]; then
+    opts="-c $HOME/.screen/base"
+  fi
+fi
+
+# Start session.
+screen $opts $session