Search code examples
sshssh-tunneltunneling

Unable to access remote website with SSH tunnel. Local port forwarding not working


What I'm trying to do is for learning purpose only and I'd need some help understanding as where and what is going wrong with the SSH tunnel that I created for accessing a remote website. Here is the setup:

  1. SSH server is running on Raspberry Pi, which is on my local network and behind the router. IP: 192.168.1.3
  2. Laptop, which is going to make connection to SSH server and a tunnel to access a remote website. IP: 192.168.1.6

Process:

  1. Connect to SSH server with following command: ssh -L 2000:www.ibm.com:80 -i ~/.ssh/RaspberryPi [email protected]
  2. Key in localhost:2000 in browser to get the webpage

Per my understanding, when localhost:2000 in entered in a browser, www.ibm.com webpage should show up. However, I get a page with message The requested URL "[no URL]", is invalid. shows up.

Not sure, what is wrong here.


Solution

  • Your assumptions are correct.

    Just take into account that are more things involved in connect to an url like redirections, http vs https and son on.

    Try with another server. For example:

    ssh -L 2000:ip-api.com:80 -i ~/.ssh/RaspberryPi [email protected]

    and browse to localhost:2000 or localhost:2000/json/24.48.0.1