pahaz / sshtunnel

SSH tunnels to remote server.
MIT License
1.23k stars 184 forks source link

Tunnel forward from local network device to VPS #278

Open EugeneRymarev opened 1 year ago

EugeneRymarev commented 1 year ago

How to forward a tunnel from a device from the local network to the VPS?

with sshtunnel.open_tunnel(
    ssh_address_or_host=('VPS_IP', VPS_PORT),
    ssh_pkey='./id_rsa',
    ssh_username='user',
    remote_bind_address=('127.0.0.1', 60080),
    local_bind_address=(
            input('IP: ') or '192.168.88.1',
            int(input('Port [80]: ') or '80')
    )
) as server2:
    server2.start()
    print(server2)
    while True:
        time.sleep(1)

i receive next error

Problem setting SSH Forwarder up: Couldn't open tunnel 192.168.88.1:80 <> 127.0.0.1:60080 might be in use or destination not reachable ... sshtunnel.HandlerSSHTunnelForwarderError: An error occurred while opening tunnels.

Command ssh -p VPS_PORT -N -R 127.0.0.1:60080:192.168.88.1:80 user@VPS_IP works fine for me.

rlkandela commented 1 year ago

I am also having this issue, I have tried all kinds of combinations, but reading the documentations seems that all of those parameters get translated to -L xxxx:yyyy:zzzz and not to -R xxxx:yyyyy:zzzz

-R IP:PORT [IP:PORT ...] ... Equivalent to ssh -Lxxxx:IP_ADDRESS:PORT

And

-L [IP:PORT ...] Equivalent to ssh -LPORT:xxxxxxxxx:xxxx, being the local IP address optional.

I guess there is no support and therefore no way of doing it.