tcpssh-tunnelpython-sockets

Can't connect to server through pinggy tcp ssh tunnel


I am trying to setup TCP communication between a client and a server in different networks. Since I do not own a public server and don't want to setup port forwarding, an option was to use TCP tunneling services like pinggy.

I use pinggy through an SSH session to their servers. A tunnel is created with the following command:

ssh -p 443 -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -R0:localhost:5000 tcp@a.pinggy.io

I set up a simple server.py like this:

import socket

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(('127.0.0.1', 5000))

server.listen()
while True:
    conn, addr = server.accept()
    print(f"Connection attempt: {addr}")

and a client.py:

import socket

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(("...a.free.pinggy.link", 33143))

The IP and port for the client are provided by the tunneling service which is setup to forward anything from their servers to my localhost:5000

I first run the server.py and then the client.py on my computer. The client finishes without error, yet there is never a connection attempt detected at the server.

Every time an attempt is done to connect to the pinggy tunnel, the interface correctly shows this and increments the total connections, so that part seems to be setup correctly. The signal seemingly just isn't forwarded / received by the server.


Solution

  • It is not clear whether you are in Windows / Linux / Mac. But as per Pinggy FAQ, windows ssh client sometimes has difficulty in connecting to domains such as "localhost". So it is recommended to use the IP address in the command.

    ssh -p 443 -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -R0:127.0.0.1:5000 tcp@a.pinggy.io