ssh-bridge: contained tailscale+sshd jump host add-on
This commit is contained in:
1 parent
5df8d11b1e
commit
14081ac81d
5 files changed
+177
No files matched your search
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/ash
|
||||
set -e
|
||||
|
||||
# Persistent state lives in the add-on's /data (survives restarts/HAOS updates).
|
||||
mkdir -p /data/ssh
|
||||
|
||||
# --- tailscaled (real TUN inside this container's netns; host never joins tailnet)
|
||||
tailscaled \
|
||||
--statedir=/data/tailscale \
|
||||
--tun=tailscale0 \
|
||||
--loginfoleak=false &
|
||||
TAILSD=$!
|
||||
|
||||
# Wait for the socket before trying to bring the node up.
|
||||
i=0
|
||||
until [ -e /data/tailscale/tailscaled.sock ]; do
|
||||
i=$((i+1)); [ "$i" -gt 30 ] && { echo "tailscaled socket never appeared"; exit 1; }
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Auth key is a file in /share (never shown in the add-on options UI).
|
||||
if [ -r /share/ssh-bridge/tailscale_authkey ]; then
|
||||
AUTHKEY="$(cat /share/ssh-bridge/tailscale_authkey)"
|
||||
# shellcheck disable=SC2086
|
||||
tailscale up \
|
||||
--authkey="$AUTHKEY" \
|
||||
--hostname="${tailscale_hostname:-ssh-bridge}" \
|
||||
--accept-dns=false \
|
||||
${tailscale_extra_args} \
|
||||
--reset
|
||||
unset AUTHKEY
|
||||
else
|
||||
echo "WARN: /share/ssh-bridge/tailscale_authkey missing; tailscale node not registered"
|
||||
fi
|
||||
|
||||
# --- sshd host key (generated once, kept in /data)
|
||||
if [ ! -f /data/ssh/ssh_host_ed25519_key ]; then
|
||||
ssh-keygen -q -t ed25519 -N "" -f /data/ssh/ssh_host_ed25519_key
|
||||
fi
|
||||
|
||||
# --- sshd in foreground; supervisor restarts the add-on if it dies
|
||||
exec /usr/sbin/sshd -D -f /etc/ssh/sshd_config -e
|
||||
Reference in new issue
Block a user