Skip to content

Instantly share code, notes, and snippets.

@sobstel
Created February 24, 2015 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sobstel/a0dec70a91f9d0f7c867 to your computer and use it in GitHub Desktop.
Save sobstel/a0dec70a91f9d0f7c867 to your computer and use it in GitHub Desktop.
Connecting to remote server local services via SSH tunnel
# SSH tunnel, so it's possible to connect to remote server services via SSH
# argument: local_port, dest_port, host
ssh_tunnel () {
lsof -i:$1 > /dev/null 2>&1 || ssh -fNg -L $1:127.0.0.1:$2 $3
}
# sample: mysql
ssh_tunnel 3307 3306 HOST
# sample: rabbitmq
ssh_tunnel 7673 7673 HOST
ssh_tunnel 7674 7674 HOST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment