From 12bef8ad79bd7ad44012f8a86cad69411ee1d8ea Mon Sep 17 00:00:00 2001 From: Artur Boryƛ Date: Fri, 9 Jul 2021 17:49:55 +0200 Subject: [sshadvanced] Remote to local forwarding section --- sshadvanced.html | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'sshadvanced.html') diff --git a/sshadvanced.html b/sshadvanced.html index ef39b89..53c7cb7 100644 --- a/sshadvanced.html +++ b/sshadvanced.html @@ -153,6 +153,33 @@ Host *

Please, remember, this works only on TCP based services, not UDP based.

+

Remote to local

+

+ There might come a need for you to open your locally running service (for example a game server) to external connections. + Let's say you can't or don't want to set up port forwarding on your router. +

+

+ You can use SSH to forward any traffic that is coming to a port on remote server to a port on your local network host. + The same as in the case "Local to remote", but the other way around. +

+

+ However, there is one additional step that is neccessary and requires you to have a root access to the remote server. You have to + edit /etc/ssh/sshd_config file, to instruct SSH server to route traffic to the other end of SSH connection - your device. +
+ Find and uncomment or append the one of the following lines to the file: +

GatewayPorts yes # to allow all remote devices
+GatewayPorts clientspecified # to allow only specific remote devices
+
+

+

You can then specify the forwarding rule with the -R option, for example open 192.168.178.2:21 on your local network, + to be accessible from a remote server on port 2100: +

ssh -R 2100:localhost:21 username@example.com
+

+

...or provide access only to your friend with an IP 111.111.111.111: +

ssh -R 111.111.111.111:2100:localhost:21 username@example.com

+

+ You can replace localhost with any host accessible from your local device, for example your local media server etc. +