I want to establish an SSH tunnel on an existing connection. The tricky part is doing it from a script (a custom shell I need to allow users only some specific things, like setting up this tunnel).
Normally you can do:
<enter> ~C ssh> -L 8080:localhost:80
But I need to be able to do this from a running python script. I tried:
print("\n~C -L 8080:localhost:80")
but that unfortunately was too simple a thought.
So, how do I setup the tunnel from a running Python script?
(as a side-issue, I also have to prevent
ssh -N -L x:host:y host.example.com, but still allow port forwards to be set up with my custom shell).