feat(framework): VM_PORT support in remote.sh for HAOS debug SSH [#344]
This commit is contained in:
+3
-9
@@ -5,12 +5,6 @@ A commit is blocked while any task below remains unchecked.
|
|||||||
|
|
||||||
## Current Tasks
|
## Current Tasks
|
||||||
|
|
||||||
(all done — session state persisted to Redmine #439/#341/#458/#459,
|
- [x] BT dongle 047d:105e passthrough to pfv-bms VM 100 (usb2) [#344]
|
||||||
Discourse audit #298 replies #37/#38, and git)
|
- [x] DNS: pfv-bms-lan.knel.net A 192.168.3.12 (LAN path) [#344]
|
||||||
|
- [x] remote.sh VM_PORT support (HAOS debug SSH 22222) [#344]
|
||||||
- [x] PDU AP7830 verdict: metered, LibreNMS graphs Output Current (#439)
|
|
||||||
- [x] tsys1 nut-server restart + HA reachability both UPS (#439, #456)
|
|
||||||
- [x] Sensor stack TDD + deploy: 6 hosts, scoped ACLs, verified (#341, #458)
|
|
||||||
- [x] Security hardening rulings a+b executed + verified (#439, #458)
|
|
||||||
- [x] HA founder handoff steps written to #439
|
|
||||||
- [x] Tickets spawned: #455 upsmon fleet, #456/#458 AWX shadows, #457 tuning, #459 tsys4 egress (fixed)
|
|
||||||
|
|||||||
+10
-8
@@ -14,6 +14,7 @@
|
|||||||
# PROX_USER (default root) SSH user on Proxmox
|
# PROX_USER (default root) SSH user on Proxmox
|
||||||
# VM_IP (default 192.168.3.50) sandbox VM IP
|
# VM_IP (default 192.168.3.50) sandbox VM IP
|
||||||
# VM_USER (default localuser) SSH user on the VM (has passwordless sudo)
|
# VM_USER (default localuser) SSH user on the VM (has passwordless sudo)
|
||||||
|
# VM_PORT (default 22) SSH port on the VM (e.g. 22222 for HAOS)
|
||||||
#
|
#
|
||||||
# USAGE:
|
# USAGE:
|
||||||
# remote.sh prox <cmd...> run command on Proxmox
|
# remote.sh prox <cmd...> run command on Proxmox
|
||||||
@@ -30,26 +31,27 @@ PROX_HOST="${PROX_HOST:-pfv-tsys5}"
|
|||||||
PROX_USER="${PROX_USER:-root}"
|
PROX_USER="${PROX_USER:-root}"
|
||||||
VM_IP="${VM_IP:-192.168.3.50}"
|
VM_IP="${VM_IP:-192.168.3.50}"
|
||||||
VM_USER="${VM_USER:-localuser}"
|
VM_USER="${VM_USER:-localuser}"
|
||||||
|
VM_PORT="${VM_PORT:-22}"
|
||||||
|
|
||||||
SSH_OPTS=(-o BatchMode=yes -o StrictHostKeyChecking=accept-new -o ConnectTimeout=15)
|
SSH_OPTS=(-o BatchMode=yes -o StrictHostKeyChecking=accept-new -o ConnectTimeout=15)
|
||||||
|
|
||||||
die() { echo "remote.sh: $*" >&2; exit 1; }
|
die() { echo "remote.sh: $*" >&2; exit 1; }
|
||||||
|
|
||||||
_prox() { ssh "${SSH_OPTS[@]}" "${PROX_USER}@${PROX_HOST}" "$@"; }
|
_prox() { ssh "${SSH_OPTS[@]}" "${PROX_USER}@${PROX_HOST}" "$@"; }
|
||||||
_vm() { ssh "${SSH_OPTS[@]}" "${VM_USER}@${VM_IP}" "$@"; }
|
_vm() { ssh "${SSH_OPTS[@]}" -p "${VM_PORT}" "${VM_USER}@${VM_IP}" "$@"; }
|
||||||
_vmroot() { _vm "sudo -n bash -c $(printf '%q' "$*")"; }
|
_vmroot() { _vm "sudo -n bash -c $(printf '%q' "$*")"; }
|
||||||
|
|
||||||
_copy() {
|
_copy() {
|
||||||
# $1=target user@host, $2=local, $3=remote dest
|
# $1=target user@host, $2=local, $3=remote dest, $4=ssh port
|
||||||
# Use cat-over-ssh (portable: no rsync needed on either side). rsync is only
|
# Use cat-over-ssh (portable: no rsync needed on either side). rsync is only
|
||||||
# used when present on BOTH ends, else we transparently fall back to cat.
|
# used when present on BOTH ends, else we transparently fall back to cat.
|
||||||
local target="$1" local="$2" dest="$3"
|
local target="$1" local="$2" dest="$3" port="${4:-22}"
|
||||||
local userhost="${target%@*}@${target#*@}"
|
local userhost="${target%@*}@${target#*@}"
|
||||||
if command -v rsync >/dev/null 2>&1 \
|
if command -v rsync >/dev/null 2>&1 \
|
||||||
&& ssh "${SSH_OPTS[@]}" "$userhost" 'command -v rsync' >/dev/null 2>&1; then
|
&& ssh "${SSH_OPTS[@]}" -p "$port" "$userhost" 'command -v rsync' >/dev/null 2>&1; then
|
||||||
rsync -az -e "ssh ${SSH_OPTS[*]}" "$local" "${userhost}:${dest}"
|
rsync -az -e "ssh ${SSH_OPTS[*]} -p $port" "$local" "${userhost}:${dest}"
|
||||||
else
|
else
|
||||||
ssh "${SSH_OPTS[@]}" "$userhost" "cat > '$dest'" < "$local"
|
ssh "${SSH_OPTS[@]}" -p "$port" "$userhost" "cat > '$dest'" < "$local"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,8 +62,8 @@ case "$mode" in
|
|||||||
vmroot) [ "$#" -ge 1 ] || die "need command"; _vmroot "$*" ;;
|
vmroot) [ "$#" -ge 1 ] || die "need command"; _vmroot "$*" ;;
|
||||||
prox-file) [ -f "${1:-}" ] || die "need local script file"; _prox "bash -s" < "$1" ;;
|
prox-file) [ -f "${1:-}" ] || die "need local script file"; _prox "bash -s" < "$1" ;;
|
||||||
vm-file) [ -f "${1:-}" ] || die "need local script file"; _vm "bash -s" < "$1" ;;
|
vm-file) [ -f "${1:-}" ] || die "need local script file"; _vm "bash -s" < "$1" ;;
|
||||||
vm-copy) [ -f "${1:-}" ] || die "need local file"; _copy "${VM_USER}@${VM_IP}" "$1" "${2:-}" ;;
|
vm-copy) [ -f "${1:-}" ] || die "need local file"; _copy "${VM_USER}@${VM_IP}" "$1" "${2:-}" "${VM_PORT}" ;;
|
||||||
prox-copy) [ -f "${1:-}" ] || die "need local file"; _copy "${PROX_USER}@${PROX_HOST}" "$1" "${2:-}" ;;
|
prox-copy) [ -f "${1:-}" ] || die "need local file"; _copy "${PROX_USER}@${PROX_HOST}" "$1" "${2:-}" 22 ;;
|
||||||
""|-h|--help|help) sed -n '2,40p' "${BASH_SOURCE[0]}" >&2; exit 0 ;;
|
""|-h|--help|help) sed -n '2,40p' "${BASH_SOURCE[0]}" >&2; exit 0 ;;
|
||||||
*) die "unknown mode '$mode'. Run '$0 help'." ;;
|
*) die "unknown mode '$mode'. Run '$0 help'." ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user