Skip to content

Instantly share code, notes, and snippets.

@zhanglianxin
Created March 11, 2019 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhanglianxin/fee0ea5b9bdf686670f81f66c3bfec4a to your computer and use it in GitHub Desktop.
Save zhanglianxin/fee0ea5b9bdf686670f81f66c3bfec4a to your computer and use it in GitHub Desktop.

SSH - Port Forwarding - Local

Forward local service running on remote to local client in localhost.

mysql -h host -u demo -psecret demo_db # cannot connect directly
ssh -L 13306:127.0.0.1:3306 demo@host # exec on local
mysql -h 127.0.0.1 -P 13306 -u demo -psecret demo_db # exec on local

SSH - Port Forwarding - Remote

Expose local service running on localhost to local client in remote.

ssh -R 16379:127.0.0.1:6379 demo@host # exec on local
ssh root@host -p 22 # login into remote
redis-cli -h 127.0.0.1 -p 16379 # exec on remote

SSH - Port Forwarding - SOCKS

ssh -D 1337 demo@host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment