Created
September 20, 2019 16:19
-
-
Save huangsam/5318c0fd1b2edbd38034316b2563e701 to your computer and use it in GitHub Desktop.
Bash function for creating a SSH tunnel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ssh_tunnel() { | |
target_host="$1" | |
target_port="$2" | |
tunnel_host="$3" | |
source_port="$4" | |
[[ `ps axu | grep $target_port | grep ssh` ]] && return | |
ssh -Nf -L "$source_port:$target_host:$target_port" "$tunnel_host" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment