networking - How To Chain SSH Tunnels -


i trying set simple ssh tunnels chain.

i have following machines:

  1. local machine, @ 10.0.0.1.
  2. remote machine, @ 10.0.0.2.

i have following programs:

  1. 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() 
  2. 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:

  1. 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.

  2. 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.

  3. 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.

  4. 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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -