Skip to content

Instantly share code, notes, and snippets.

@huyby
Created March 6, 2017 13:46
Show Gist options
  • Save huyby/b32322cfe9430de144444539118d1abd to your computer and use it in GitHub Desktop.
Save huyby/b32322cfe9430de144444539118d1abd to your computer and use it in GitHub Desktop.
SSH port forwarding commands; useful for forwarding a remote database connection over SSH in combination with other configurations like a jump host (bastion)
# Overview on SSH port forwarding: http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html
# Example of MySQL database connection tunnel using a jump host
ssh -F ./ssh.cfg -nNT -L 33060:localhost:3306 remotehost
# ./.ssh.cfg contents
Host bastion
Hostname 8.8.8.8
User bastion-user
Host 10.0.1.*
User internal-host-user
ProxyJump bastion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment