First, to test, set up temporary Python http server on the remote host:
[user@remotehost ~]$ mkdir tmp && cd tmp
[user@remotehost tmp]$ echo "HELLO WORLD" > index.html
[user@remotehost tmp]$ python -m http.server 8080 # python3
Serving HTTP on 0.0.0.0 port 8080 ...
[user@remotehost tmp]$ python -m SimpleHTTPServer 8080 #python2
Serving HTTP on 0.0.0.0 port 8080 ...
Then on the localhost use ssh to set up a tunnel. Here port 8081 on the local machine will tunnel through to 8080 on the remote host:
user@localhost ~ $ ssh -p 443 -f user@remotehost.com -L 8081:127.0.0.1:8080 -N
user@remotehost.com's password:
-p for remote sshd port (default is 22).-f tells ssh to go into the background just before it executes the command. This is followed by the username and server you are logging into.-L 8081:127.0.0.1:8080 is in the form of -L local-port:host:remote-port. Here the I'm using the loopback for the host, this refers to the remote host's loopback interface.-N instructs OpenSSH to not execute a command on the remote system.Test the tunnel with telnet on local machine.
user@localhost ~ $ telnet 127.0.0.1 8081
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
GET /
HELLO WORLD
Connection closed by foreign host.