From: eostre Date: Fri, 4 Sep 2020 18:01:36 +0000 (-0400) Subject: update client.sh X-Git-Url: https://vcs.fsf.org/?p=eostre.git;a=commitdiff_plain;h=e29d3a456b71d5070120ebf93fa39b8e64f839b3 update client.sh --- diff --git a/meatviewer/client.sh b/meatviewer/client.sh new file mode 100755 index 0000000..12633a3 --- /dev/null +++ b/meatviewer/client.sh @@ -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