networking - How To Chain SSH Tunnels -
i trying set simple ssh tunnels chain.
i have following machines:
- local machine, @ 10.0.0.1.
- remote machine, @ 10.0.0.2.
i have following programs:
client.py:
import socket client_host = [...] client_port = [...] sock = socket.socket(socket.af_inet, socket.sock_stream) sock.setsockopt(socket.sol_socket, socket.so_reuseaddr, 1) sock.connect((client_host, client_port)) sock.send('test') sock.close()
server.py:
import socket server_host = [...] server_port = [...] server = socket.socket(socket.af_inet, socket.sock_stream) server.setsockopt(socket.sol_socket, socket.so_reuseaddr, 1) server.bind((server_host, server_port)) server.listen(1) client = server.accept()[0] print client.recv(1024) client.close() server.close()
now:
i run client.py (client_host='127.0.0.1', client_port=8000) , server.py (server_host='', server_port=8000) on same machine, , works expected.
i run client.py (client_host='127.0.0.1', client_port=8000) on local machine, , server.py (server_host='', server_port=8001) on remote machine. run putty , add local ssh tunnel source port 8000 , destination 10.0.0.2:8001, , works expected.
i run client.py (client_host='127.0.0.1', client_port=8001) on remote machine, , server.py (server_host='', server_port=8002) on local machine. run putty , add remote ssh tunnel source port 8001 , destination 127.0.0.1:8002, , works expected.
however, when run client.py (client_host='127.0.0.1', client_port=8000) , server.py (server_host='', server_port=8002) on local machine, , run 2 puttys, 1 local ssh tunnel source port 8000 destination 10.0.0.2:8001, , 1 remote ssh tunnel source port 8001 destination 127.0.0.1:8002, nothing happens.
as see it, message client.py should sent local machine's port 8000, putty listens , should redirect via ssh remote machine's port 8001, putty listens , should redirect via ssh local machine's port 8002, should reach server.py.
what wrong, , how fix it?
thanks.
you need tick 'local ports accept connections other hosts' , 'remote ports same'.
by way, netcat
more useful standard utility trying kind of thing out, if it's available on os.
Comments
Post a Comment