Författare:
Per Stenebo
Skapad:
2017-02-20 07:21:18
Ändrad:
2019-07-26 06:41:14
en

Local port forward in SSH

 

How to access a service behind a gateway in SSH.

| Ubuntu SSH manpage | Ubuntu help |

Tell the gateway to forward a service port from the source to a port on my local computer.

Syntax:

ssh -L "destination local port":"source host":"source port" -N "gateway-user"@"gateway host" -g

Example 1. Forward web interface on hostB, who is behind hostA, to port 8080 on my local machine:

ssh -L 8080:hostB:80 -N hostA

Access interface with: http://localhost:8080, like in a web browser.

Example 2:

ssh -L 10554:192.168.0.100:554 -N me@78.72.77.23 -g

Access the service on port 10554 on your local machine (RTSP network stream in VLC in this example):

rtsp://localhost:10554/defaultPrimary0?streamType=u

Option -L forwards local TCP port to remote host.

Option -N Do not execute a remote command.  This is useful for just forwarding ports.

Option -g makes the service available at all interfaces on the destination host.

 

Kommentarer till sidan Local port forward