segfault/gsnc/sf-gsnc.sh
2023-04-26 18:57:44 +01:00

19 lines
621 B
Bash
Executable File

#! /bin/bash
[[ -z $SF_SEED ]] && { echo >&2 "SF_SEED= not set"; sleep 5; exit 255; }
ip route del default
ip route add default via 172.22.0.254
# This is the GS_SECRET to get to SSHD (and gs-netcat in cleartext [-C] could be used).
# It can be cryptographically weak. The security is provided by SSHD.
GS_SECRET=$(echo -n "GS-${SF_SEED}${SF_FQDN}" | sha512sum | base64 -w0)
GS_SECRET="${GS_SECRET//[^[:alpha:]]}"
GS_SECRET="${GS_SECRET:0:12}"
echo "${GS_SECRET}" >/config/guest/gsnc-access-22.txt
# Give sf-router time to boot up and set the routes...
sleep 3
exec /gs-netcat -l -d "$1" -p 22 -s "22-${GS_SECRET}"