Last active
November 14, 2019 03:08
-
-
Save ledangtuanbk/3e147d08c9ea9f1f3716b42ee48f82e4 to your computer and use it in GitHub Desktop.
How to use ssh_tunnel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Connecting to a database behind a firewall | |
ssh -L 9000:localhost:5432 user@example.com database postgres run port 5432 only access from localhost | |
2. Remote port forwarding | |
ssh -R 9000:localhost:3000 user@example.com | |
Localhost running port 3000 and want to acess from internet port 9000 | |
- set GatewayPorts yes in /etc/ssh/sshd_config | |
- this can be done by autossh | |
autossh -M 0 -f -q -N -o "ServerAliveInterval 5" -o "ServerAliveCountMax 1" -o "ExitOnForwardFailure yes" -R 0.0.0.0:[SERVER]:localhost:[CLIENT_IP] [SERVER_USER]@[SEVER_IP] | |
- remember to run on reboot | |
@reboot /root/ssh_tuner.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment