Issue
I tried translate command
ssh -R 80:localhost:8080 [email protected]
(It works as it should, problem not in server)
to Paramiko with help of href="https://github.com/paramiko/paramiko/blob/master/demos/rforward.py" rel="nofollow noreferrer">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
Solution
-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
).
Answered By - Martin Prikryl Answer Checked By - David Goodson (WPSolving Volunteer)