Initial Awawawa
This commit is contained in:
36
sshd/patchbay-sshd
Executable file
36
sshd/patchbay-sshd
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
# Starts the dedicated PatchBay sshd in the foreground. Used by all init systems.
|
||||
# Usage: patchbay-sshd [config] (default /etc/patchbay/patchbay.conf)
|
||||
set -eu
|
||||
|
||||
CONF=${1:-/etc/patchbay/patchbay.conf}
|
||||
LIBDIR=$(dirname "$(readlink -f "$0")")
|
||||
PATCHBAYD=${PATCHBAYD:-patchbayd}
|
||||
SSHD=${SSHD:-$(command -v sshd || echo /usr/sbin/sshd)}
|
||||
|
||||
get() {
|
||||
"$PATCHBAYD" -c "$CONF" --print-config | sed -n "s/^$1=//p"
|
||||
}
|
||||
|
||||
RUNDIR=$(get RunDir)
|
||||
HOSTKEY=$(get SSHHostKey)
|
||||
mkdir -p "$RUNDIR" /run/sshd
|
||||
chmod 755 "$RUNDIR"
|
||||
|
||||
if [ ! -f "$HOSTKEY" ]; then
|
||||
ssh-keygen -q -t ed25519 -N '' -C patchbay-target -f "$HOSTKEY"
|
||||
fi
|
||||
|
||||
# authorized_keys must exist before sshd accepts connections.
|
||||
"$PATCHBAYD" -c "$CONF" --write-keys
|
||||
|
||||
sed -e "s|@PORT@|$(get TargetPort)|" \
|
||||
-e "s|@HUBPORT@|$(get HubPort)|" \
|
||||
-e "s|@HOSTKEY@|$HOSTKEY|" \
|
||||
-e "s|@AUTHKEYS@|$(get AuthorizedKeys)|" \
|
||||
-e "s|@USER@|$(get SSHUser)|" \
|
||||
-e "s|@RUNDIR@|$RUNDIR|" \
|
||||
"$LIBDIR/sshd_config.in" > "$RUNDIR/sshd_config"
|
||||
|
||||
"$SSHD" -t -f "$RUNDIR/sshd_config"
|
||||
exec "$SSHD" -D -e -f "$RUNDIR/sshd_config"
|
||||
Reference in New Issue
Block a user