Many apps have a web page that should not be open to the whole Internet, for example an admin page or a program without a good login. The safest setting is to let it listen only on 127.0.0.1, the server itself. You can still open it from your computer: an SSH tunnel carries the page through your encrypted SSH connection. Nothing else has to be opened in the firewall. Tested from a Linux computer to our Ubuntu 26.04 LTS test server; the same works from macOS and from Windows with the built-in OpenSSH.


1. The App Listens Only on the Server

Check which address the app uses (more in See Which Programs Listen on Your Linux Server):

ss -tlnp 'sport = :8099'

127.0.0.1:8099 means: only from the server itself. A connection from outside to port 8099 is refused, as it should be.

2. Start the Tunnel on Your Computer

Open a terminal (on Windows: PowerShell) and run, with the port of the app, your user name and your server:

ssh -L 8099:127.0.0.1:8099 root@203.0.113.10

Read it as: port 8099 on my computer leads to 127.0.0.1:8099 on the server. Log in as usual and leave this window open.

3. Open the Page

On your computer, open http://127.0.0.1:8099 in the browser. The page of the app appears, although it is not reachable from the Internet. Closing the SSH window closes the tunnel.

Useful Variations

  • If port 8099 is already used on your computer, choose another one on the left: -L 18099:127.0.0.1:8099, then open http://127.0.0.1:18099.
  • Several apps at once: repeat -L, for example -L 8096:127.0.0.1:8096 -L 7878:127.0.0.1:7878.
  • Only the tunnel, without a command prompt: add -N. The window then shows nothing; stop it with Ctrl+C.
  • For Docker apps, publish the port only on the server: "127.0.0.1:7878:7878" in the compose file.

With an SSH key you are not asked for a password each time: Log In to Your Linux Server With an SSH Key.


Related Guides

View all Linux guides

Was this answer helpful? 0 Users Found This Useful (0 Votes)