update client.sh
authoreostre <eostre.danne@protonmail.com>
Fri, 4 Sep 2020 18:01:36 +0000 (14:01 -0400)
committereostre <eostre.danne@protonmail.com>
Fri, 4 Sep 2020 18:01:36 +0000 (14:01 -0400)
meatviewer/client.sh [new file with mode: 0755]

diff --git a/meatviewer/client.sh b/meatviewer/client.sh
new file mode 100755 (executable)
index 0000000..12633a3
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/bash -xe
+
+function print_usage {
+       set +x
+       echo \
+"
+usage: $0 PORT REMOTE_PORT user@proxy
+       script that sets up a reverse ssh tunnel
+       PORT is the port that your techy needs access to. In general, for graphical issues use 5900 and for command-line issues use 22
+       REMOTE_PORT is the port that you'll get on the proxy server, any number over 1000 works as long as you and your techy plug in the same number. This number gets used as a kind of identifier for your remote support session.
+       USER is just your username at the remote proxy machine, if left blank it is assumed to be the same as your username on your local machine
+"
+       set -x
+       exit
+}
+
+function get_techy_sshauth {
+       SSH_PUBKEY=$(curl http://$PROXY/$REMOTE_PORT) || GET_PUBKEY_OVER_HTTP_FAILED=true
+       if [ -n "$SSH_PUBKEY" ]; then GET_PUBKEY_OVER_HTTP_FAILED=true; fi
+       if [ "$GET_PUBKEY_OVER_HTTP_FAILED" -eq "true" ]; then
+               set -x
+               echo "Automatically fetching your support partner's SSH public key failed, please ask them for their public key and paste it in your terminal here:"
+               set +x
+               read -p ":>" SSH_PUBKEY
+       fi
+       set -x
+       echo "Adding your partner's SSH key to your authorized_keys, feel free to delete this line from your authorized_keys once this session is over"
+       set +x
+       echo $SSH_PUBKEY >> ~/.ssh/authorized_keys
+}
+
+if [ -n "$@" ]; then print_usage; fi
+
+PORT_TO_FORWARD=$1
+REMOTE_PORT=$2
+USER=${3:-$(whoami)}
+PROXY=e9d.org
+
+ssh -T -R $REMOTE_PORT:localhost:$PORT_TO_FORWARD $USER@$PROXY