Remote port forwarding in Paramiko

Viewed 325

I tried translate command ssh -R 80:localhost:8080 nokey@localhost.run (It works as it should, problem not in server) to Paramiko with help of https://github.com/paramiko/paramiko/blob/master/demos/rforward.py

My code:

import paramiko
from rforward import reverse_forward_tunnel
ssh = paramiko.SSHClient()

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(username="nokey", hostname="localhost.run")
transport = ssh.get_transport()
reverse_forward_tunnel(8080, "localhost.run", 80, transport)

But it fails with:

Traceback (most recent call last):    ...
raise SSHException("TCP forwarding request denied")  paramiko.ssh_exception.SSHException: TCP forwarding request denied

Help pls

1 Answers
-R 80:localhost:8080

That forwards remote port 80 to local localhost:8080.

That imo maps to reverse_forward_tunnel as

reverse_forward_tunnel(80, "localhost", 8080, transport)

Basically, the same order of arguments (and localhost, not localhost.run).

Related