How to use the forward.py script in paramiko
Paramiko is an ssh library for python.
The forward.py script expects one non-keyword argument, and a number of keyword arguments.
python forward.py example.com:22 -r 80 -p 8080 -r example.com:80 --user username --key secret_key_file_name
The above example takes the remote port 80 and makes it available locally as 8080.
The non-keyword argument above is example.com:22 . It connects to the ssh server at example.com running at port 22. 22 is not the port the forward goes to. It is simply the port where the ssh server is, and can be changed from 22 if you run an ssh server on a non-standard port.
The -p indicates the local port for the tunnel, i.e. the port your applications are going to connect to, i.e. your end of the tunnel.
The -r indicates the host and port that the remote server is going to forward to. The server indicated by -r may be different than the server you are connecting to, e.g.:
python forward.py example.com:22 -r 80 -p 8080 -r anotherhost.example.com:80 --user username --key secret_key_file_name
...in which case you are using example.com to reach anotherhost.example.com .
In normal ssh, an equivalent tunnel to the first example above could be written as:
ssh -L 8080:localhost:80 username@example.com