Remote tcp connection in python with zeromq -


i have python client needs talk remote server manage. communicate using zeromq. when tested client/server locally worked. have client , server deployed on cloud, each using different provider. question is, what's simplest way (that safe) make connection? i'm assuming can't pass password over, , if i'm guessing there safer alternatives.

i know how set ssh connection without password using ssh-keygen. work? client need make ssh connection server before sending tcp req? if there's python library helps it'd big help.

thanks!

update: more 24 hours passed , no 1 replied/answered. think i'm getting closer solve this, not quite there yet. added client's key .ssh/authorized_key on server, , can ssh client server without password. next, followed post "tunneling pyzmq connections ssh". here's have in client code:

1    context = zmq.context() 2    socket = context.socket(zmq.req) 3    socket.connect("tcp://localhost:5555") 4    ssh.tunnel_connection(socket, "tcp://locahost:5555", "myuser@remote-server-ip:5555") 5    socket.send_string(some_string) 6    reply = socket.recv() 

this doesn't work. don't understand lines 3 & 4 , assume wrong there. also, server (hosted on linode) has "default gateway" ip , "public ip" -- in tunnel connection specify public ip, ip use ssh machine.

indeed, zmq way - tunnelling connection ssh. example needs done, except 1 should either use connect or tunnel_connection, not both.

also, when specifying server connect to, make sure define ssh port, not zmq rep socket port. is, instead of myuser@remote-server-ip:5555 might try myuser@remote-server-ip or myuser@remote-server-ip:22.

import zmq import zmq.ssh context = zmq.context() socket = context.socket(zmq.req) zmq.ssh.tunnel_connection(socket, "tcp://locahost:5555", "myuser@remote-server-ip") socket.send(b"hello") reply = socket.recv() 

finally, make sure you've installed either pexpect or paramiko - tunnelling actually. note if you're using windows, paramiko solution work - pexpect openssh tunnelling won't work on windows.

if use paramiko instead of pexpect, make sure set paramiko=true in tunnel_connection arguments.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -