feat manage script
This commit is contained in:
29
config/shared/bin/ssh-forward
Executable file
29
config/shared/bin/ssh-forward
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to display usage information
|
||||
usage() {
|
||||
echo "Usage: $0 <user@host> <port1> [port2] [port3] ..."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Ensure at least two arguments are provided: host and one port
|
||||
if [ "$#" -lt 2 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
# Extract the host from the first argument
|
||||
HOST="$1"
|
||||
shift # Shift the arguments so that $@ contains the remaining ports
|
||||
|
||||
# Initialize the PORTS variable
|
||||
PORTS=""
|
||||
|
||||
# Iterate over the remaining arguments, which are the ports
|
||||
for port in "$@"; do
|
||||
PORTS="$PORTS -L ${port}:localhost:${port}"
|
||||
done
|
||||
|
||||
# Construct and run the SSH command
|
||||
SSH_CMD="ssh -N -T -o ExitOnForwardFailure=yes $HOST $PORTS"
|
||||
echo "Running: $SSH_CMD"
|
||||
$SSH_CMD
|
||||
Reference in New Issue
Block a user