Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
21 lines
601 B
Plaintext
21 lines
601 B
Plaintext
# SSH Port Forwarding Functions
|
|
fip() {
|
|
(( $# < 2 )) && echo "Usage: fip <host> <port1> [port2] ..." && return 1
|
|
local host="$1"
|
|
shift
|
|
for port in "$@"; do
|
|
ssh -f -N -L "${port}:localhost:${port}" "$host" && echo "Forwarding localhost:$port -> $host:$port"
|
|
done
|
|
}
|
|
|
|
dip() {
|
|
(( $# == 0 )) && echo "Usage: dip <port1> [port2] ..." && return 1
|
|
for port in "$@"; do
|
|
pkill -f "ssh.*-L ${port}:localhost:${port}" && echo "Stopped forwarding port $port" || echo "No forwarding on port $port"
|
|
done
|
|
}
|
|
|
|
lip() {
|
|
pgrep -af "ssh.*-L [0-9]+:localhost:[0-9]+" || echo "No active forwards"
|
|
}
|