Skip to content

Instantly share code, notes, and snippets.

@ian910297
Last active May 30, 2018 12:23
Show Gist options
  • Save ian910297/6f56995ff3da95ece634ce96afe7833e to your computer and use it in GitHub Desktop.
Save ian910297/6f56995ff3da95ece634ce96afe7833e to your computer and use it in GitHub Desktop.
If you don't have static IP address, you want to connect home from the remote-site that has static IP address. You had better use reverse tunnel
#!/bin/sh
# ssh version
# ssh parameters
# -N : Do not execute a remote command. This is useful for just forwarding ports (protocol version 2 only).
# -f : Requests ssh to go to background just before command execution.
# -R [port]:[host]:[host-port] : Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side.
# Example :
# ssh -NfR [remote port]:[localhost]:[localhost-port] user@remote.com
# I have a vm, and its ssh service listen on 22 port.
# I want to forward a connection from remote:9527 to the vm.
#ssh -NfR 9527:localhost:22 user@remote.com
# Then, you can go to the remote server
#ssh user@remote
# You can ssh localhost from the [remote port] on the remote server
#ssh -p 9527 user@localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment