17 lines
483 B
Bash
Executable file
17 lines
483 B
Bash
Executable file
#!/usr/bin/env bash
|
|
# Allows to access some web UIs through VPN
|
|
|
|
function sshtunnel {
|
|
target=$1
|
|
|
|
# get occupied ports by SSH sessions
|
|
local_used_ports=$(lsof -PiTCP -sTCP:LISTEN | grep ssh | awk -F':' '{print $2}' | uniq | grep -Eo '[0-9]{1,5}')
|
|
|
|
# define a port
|
|
local_selected_port=$(shuf -n 1 <(seq 60000 | grep -Fxv -e{$local_used_ports}))
|
|
|
|
echo "$target: https://localhost:$local_selected_port"
|
|
ssh -L $local_selected_port:$target:443 oli@10.7.1.90
|
|
}
|
|
|
|
sshtunnel $1
|