19 lines
696 B
Bash
19 lines
696 B
Bash
#!/bin/sh
|
|||
|
|
# Keep a USB-only diagnostic login available even when the main sshd's PAM
|
||
|
|
# stack is misconfigured. It is bound to 172.16.42.1 so it is never exposed
|
||
|
|
# over Wi-Fi or the modem; create /etc/bananarchy-no-debug-sshd to disable.
|
||
|
|
[ -f /etc/bananarchy-no-debug-sshd ] && exit 0
|
||
|
|
if rc-service bananarchy-sshd-debug status >/dev/null 2>&1; then
|
||
|
|
exit 0
|
||
|
|
fi
|
||
|
|
[ -x /usr/sbin/sshd ] || exit 0
|
||
|
|
[ -f /etc/ssh/ssh_host_ed25519_key ] || /usr/sbin/ssh-keygen -A >/dev/null 2>&1
|
||
|
|
# The USB gadget address may appear after this service starts, so retry.
|
||
|
|
(
|
||
|
|
i=0
|
||
|
|
while [ "$i" -lt 30 ]; do
|
||
|
|
/usr/sbin/sshd -f /etc/ssh/sshd_config_debug >/dev/null 2>&1 && break
|
||
|
|
i=$((i + 1))
|
||
|
|
sleep 2
|
||
|
|
done
|
||
|
|
) &
|