Skip to content

Instantly share code, notes, and snippets.

@magnetikonline
Last active December 25, 2018 13:03
Show Gist options
  • Save magnetikonline/3d239b82265398568f31 to your computer and use it in GitHub Desktop.
Save magnetikonline/3d239b82265398568f31 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:

  • We have connectivity to remote server (EC2 instance) REMOTE_EC2_HOST over SSH.
  • Connectivity to AWS RDS MySQL instance RDS.ENDPOINT.rds.amazonaws.com 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 \
	USERNAME@REMOTE_EC2_HOST

# connect to MySQL on 127.0.0.1:6400
$ mysql --host 127.0.0.1 --port 6400 --user MYSQL.USER --password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment