backing up shopserver1p apache config
[eostre.git] / meatviewer / client.sh
CommitLineData
e29d3a45 1#!/bin/bash -xe
2
3function print_usage {
4 set +x
5 echo \
6"
7usage: $0 PORT REMOTE_PORT user@proxy
8 script that sets up a reverse ssh tunnel
9 PORT is the port that your techy needs access to. In general, for graphical issues use 5900 and for command-line issues use 22
10 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.
11 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
12"
13 set -x
14 exit
15}
16
17function get_techy_sshauth {
18 SSH_PUBKEY=$(curl http://$PROXY/$REMOTE_PORT) || GET_PUBKEY_OVER_HTTP_FAILED=true
19 if [ -n "$SSH_PUBKEY" ]; then GET_PUBKEY_OVER_HTTP_FAILED=true; fi
20 if [ "$GET_PUBKEY_OVER_HTTP_FAILED" -eq "true" ]; then
21 set -x
22 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:"
23 set +x
24 read -p ":>" SSH_PUBKEY
25 fi
26 set -x
27 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"
28 set +x
29 echo $SSH_PUBKEY >> ~/.ssh/authorized_keys
30}
31
32if [ -n "$@" ]; then print_usage; fi
33
34PORT_TO_FORWARD=$1
35REMOTE_PORT=$2
36USER=${3:-$(whoami)}
37PROXY=e9d.org
38
39ssh -T -R $REMOTE_PORT:localhost:$PORT_TO_FORWARD $USER@$PROXY