Skip to content

Instantly share code, notes, and snippets.

@pshoukry
Last active April 13, 2017 08:56
Show Gist options
  • Save pshoukry/5c1a2b8513b0f9c1edf5a2e54c620932 to your computer and use it in GitHub Desktop.
Save pshoukry/5c1a2b8513b0f9c1edf5a2e54c620932 to your computer and use it in GitHub Desktop.
SSH-Tunnel to mysql ( RDS or normal mysql instance) from rails application
Host intermediate
User <myuser>
HostName intermediate.domain.com
ForwardAgent yes
Host frontend
User <myuser>
ProxyCommand ssh intermediate nc <frontend_ip> 22
Localforward 3307 mysql.domain.com:3306
ForwardAgent yes
FROM buildpack-deps:jessie
ADD . /root/.ssh
RUN chown -R root:root /root/.ssh
RUN apt-get update
RUN apt-get install -y mysql-client socat
expose 3306
CMD socat tcp-l:3306,fork,reuseaddr tcp:127.0.0.1:3307 & ssh -N frontend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment