Skip to content

Instantly share code, notes, and snippets.

@PharrellWANG
Created June 18, 2018 05:41
Show Gist options
  • Save PharrellWANG/55751d7dc1a3ae10f3e6b5d7eb6692ed to your computer and use it in GitHub Desktop.
Save PharrellWANG/55751d7dc1a3ae10f3e6b5d7eb6692ed to your computer and use it in GitHub Desktop.

How to access a local website on remote linux server from local machine

Problem

Now you have a website running on a remote linux server locally, e.g, tensorboard --logdir=/tmp --port=8989, and you want to visit http://localhost:8989 on your local machine.

However, the server do not have Firefox installed so you can not use X forwarding, and your username are not in sudoers file on the server so you cannot install any software without the help from sudoer.

Solution

Use SSH to forward/tunnel a single port

Step 1: On your local machine, open terminal, run your website on remote server after SSH login, e.g., tensorboard --logdir=/tmp --port=8989.

Step 2: On your local machine, open terminal, enable localhost tunneling: ssh -L 8989:localhost:8989 <your-username>@<ip-address-or-domain-name>. You need to replace <your-username> and <ip-address-or-domain-name> with appropriate username and domain name.

Step 3: After step 1 and step 2, you should have two SSH sessions active. Do not close them, head to your Chrome or any other browser on your local machine, access http://localhost:8989. Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment