create a port forwarding over 2 remote servers
Here is an example on how to create a port forwarding over 2 remote servers
Assume you can access to an application server via ssh. On this server you have access to another server with a mysql db. If you want to use this db locally, you can create a 2 step port forward
# with this commad you create the port forwarding and connect to the mysqlDB locally, which has a port forwarding to the remote mysql server
ssh -f <user>@<applicationServer> -L <localPort:<mysqlServerAdress>:<mysqlServerPort> -N; mysql -u <mysqlUser> -p<mysqlPassword> -h 127.0.0.1 -P <localPort>
# you can also disconnect and reuse the port forwarding f.e.
echo "use <database>;SHOW TABLES" | mysql -u <mysqlUser> -p<mysqlPassword> -h 127.0.0.1 -P <localPort>
Written by Ralph Meier
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Related Tags
#shell
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#