Skip to content

Instantly share code, notes, and snippets.

@hflamboauto1
Forked from magnetikonline/README.md
Created July 6, 2016 11:03
Show Gist options
  • Save hflamboauto1/128a461e129592c30a4c57f0ad0a4824 to your computer and use it in GitHub Desktop.
Save hflamboauto1/128a461e129592c30a4c57f0ad0a4824 to your computer and use it in GitHub Desktop.
SSH forward local port to remote AWS RDS MySQL instance.

SSH forward local port to remote AWS RDS instance

The scenario:

  • Connectivity to remote server (e.g. EC2 instance) over SSH.
  • Connectivity to AWS RDS MySQL instance from remote server only (due to security group/firewall settings).
# forward requests from 127.0.0.1:6400 -> RDS.ENDPOINT.rds.amazonaws.com:3306
# add [-f] switch to background ssh process
$ ssh -vvvN \
	-L 6400:RDS.ENDPOINT.rds.amazonaws.com:3306 \
	-i /path/to/rsa/private/key \
	-p 22 user@host

# connect to MySQL on 127.0.0.1:6400
$ mysql -h 127.0.0.1 -P 6400 -u MYSQL.USER -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment