forked from finn/tinyboard
fix hub onboard-spoke script: keyscan, rclone check, dir creation, tunnel verify
This commit is contained in:
@@ -26,11 +26,17 @@ read -rp "Tunnel port for $SPOKE_NAME: " TUNNEL_PORT
|
|||||||
KEY_NAME="armbian-${SPOKE_NAME}-$(date +%Y%m)"
|
KEY_NAME="armbian-${SPOKE_NAME}-$(date +%Y%m)"
|
||||||
KEY_PATH="$SSH_DIR/$KEY_NAME"
|
KEY_PATH="$SSH_DIR/$KEY_NAME"
|
||||||
|
|
||||||
|
command -v rclone >/dev/null || die "rclone is not installed"
|
||||||
|
mkdir -p "$(dirname "$RCLONE_CONF")"
|
||||||
|
|
||||||
header "Checking Tunnel"
|
header "Checking Tunnel"
|
||||||
|
info "Scanning spoke host key..."
|
||||||
|
ssh-keyscan -p "$TUNNEL_PORT" -H localhost >> "$SSH_DIR/known_hosts" 2>/dev/null
|
||||||
|
|
||||||
info "Verifying spoke is reachable on port $TUNNEL_PORT..."
|
info "Verifying spoke is reachable on port $TUNNEL_PORT..."
|
||||||
ssh -o BatchMode=yes -o ConnectTimeout=10 -p "$TUNNEL_PORT" armbian@localhost exit 2>/dev/null \
|
ssh -o BatchMode=yes -o ConnectTimeout=10 -p "$TUNNEL_PORT" armbian@localhost exit 2>/dev/null \
|
||||||
&& info "Spoke is reachable." \
|
&& info "Spoke is reachable." \
|
||||||
|| die "Cannot reach spoke on port $TUNNEL_PORT. Make sure the spoke tunnel is up."
|
|| warn "Could not verify spoke without a key yet — proceeding to key setup."
|
||||||
|
|
||||||
header "Generating Hub SSH Key"
|
header "Generating Hub SSH Key"
|
||||||
if [ -f "$KEY_PATH" ]; then
|
if [ -f "$KEY_PATH" ]; then
|
||||||
@@ -42,6 +48,7 @@ fi
|
|||||||
|
|
||||||
header "Copying Hub Key to Spoke"
|
header "Copying Hub Key to Spoke"
|
||||||
info "Running ssh-copy-id to armbian@localhost:$TUNNEL_PORT..."
|
info "Running ssh-copy-id to armbian@localhost:$TUNNEL_PORT..."
|
||||||
|
info "(You will be prompted for the armbian password on the spoke)"
|
||||||
ssh-copy-id -i "$KEY_PATH.pub" -p "$TUNNEL_PORT" armbian@localhost
|
ssh-copy-id -i "$KEY_PATH.pub" -p "$TUNNEL_PORT" armbian@localhost
|
||||||
info "Key copied."
|
info "Key copied."
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user