I have a python client that needs to talk to a remote server that I am managing. They exchange data using zeromq. When I tested the client / server, everything worked. But now I have a client and server deployed in the cloud, each of which uses a different provider. My question is: what is the easiest way (secure) to make a connection? I assume that I can not pass the password, and even if I could assume that there are more secure alternatives.
I know how to establish an ssh connection without a password using ssh-keygen. Will this work? Will the client have to make an ssh connection to the server before sending tcp req? If there is a python library to help with this, that will be a big help.
Thank!
Update : So more than 24 hours have passed, and no one answered or answered. I think I'm getting closer to solve this, but not quite yet. I added my client key to .ssh / authorized_key on the server, and now I can ssh from client to server without a password. Then I followed this post on “Tuning PyZMQ Connections with SSH”. Here is what I have in my 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 does not work. I really do not understand lines 3 and 4, and I suppose that I am something wrong. In addition, my server (hosted on linode) has the IP address “Default Gateway” and “Public IP” - in the tunnel connection, I specify only the public ip, which is also the ip that I use for ssh on the machine.