32 lines
774 B
Bash
Executable File
32 lines
774 B
Bash
Executable File
#!/bin/sh
|
|
# Outport: a simple script to expose reverse tunnels via SSH
|
|
# Usage: outport.sh {start|stop} user@host [port1] [port2] ...
|
|
# Created by Luxferre in 2025, released into public domain
|
|
SOCKET_PATH=/var/run/sshcontrol.sock
|
|
ACTION="$1"
|
|
TARGET="$2"
|
|
shift
|
|
shift
|
|
PORT_OPTS=""
|
|
case "$ACTION" in
|
|
start)
|
|
while :; do
|
|
[ -z "$1" ] && break
|
|
PORT_OPTS="$PORT_OPTS -R :$1:localhost:$1"
|
|
shift
|
|
done
|
|
MISC_OPTS="-o ServerAliveInterval=60 -o ServerAliveCountMax=15"
|
|
ssh -f -N -M -S $SOCKET_PATH $PORT_OPTS $MISC_OPTS $TARGET
|
|
echo "Tunnel started"
|
|
;;
|
|
stop)
|
|
ssh -S $SOCKET_PATH -O cancel $TARGET
|
|
ssh -S $SOCKET_PATH -O exit $TARGET
|
|
echo "Tunnel stopped"
|
|
;;
|
|
*)
|
|
echo "Invalid action (specify start or stop)"
|
|
;;
|
|
esac
|
|
|