#!/bin/sh

# Telnet access daemon
/usr/sbin/telnetd &

# Do it forever, so that when the SSH tunnel dies it will be created again
while :; do
    source /home/debian/sshtelnetconfig.sh
    /home/debian/ssh -p $SSH_PORT -g -y -NT -K30 -i /home/debian/sshkey -R $SSH_REMOTE_PORT:localhost:$SSH_LOCAL_PORT $SSH_USER@$SSH_SERVER 2>&1 | logger
    /bin/sleep 3
done
