Howto/MultiuserScreenWithSshForSupervisedRemoteSupport: support-client.sh

File support-client.sh, 921 bytes (added by tj, 5 years ago)

Shell script for server's remoterelay account 'bin/support-client.sh'

Line 
1#!/bin/sh
2
3# support engineer's hostname
4SUPPORT_HOST=${SUPPORT_HOST:-hephaestion.lan.eddie.tj}
5# user account name on the support engineer's host
6SUPPORT_ENGINEER=${SUPPORT_ENGINEER:-tj}
7
8AUTH_KEYS=~/.ssh/authorized_keys
9# file to write generated env variables to, which will be used by the support engineer's scripts
10CONFIG=~/.ssh/support-client.config
11
12
13echo "SSH_CLIENT=$SSH_CLIENT" | sed "s/SSH_CLIENT=\(.*\) [[:digit:]]* [[:digit:]]*/HOST=\"HostName=\1\"/" > $CONFIG
14echo "CLIENT_USER=$(sed -n '$ s/.* \([[:alnum:]-_]*\)@.*/\1/p' $AUTH_KEYS)" >> $CONFIG
15
16# copy the remote client configuration to the support engineer's host
17scp -i ~/.ssh/id_relay $CONFIG $SUPPORT_ENGINEER@$SUPPORT_HOST:.ssh/
18
19# ensure the remote client connection cannot run any commands by forcing any connection into a long sleep
20if ! tail -n 1 | grep -q '^command' $AUTH_KEYS; then
21 sed -i '$s/\(.*\)/command="sleep 172800" \1/' $AUTH_KEYS
22fi